I'm trying to create a workaround for Conky's truncation of usernames with the top user function. Using id -nu $uid, I tried this:

${exec id -nu ${top uid \1}}

which leads to "bad substitution" errors. Thinking that it may be because the top function is sending a string instead of an integer, I tried creating a lua function:

function conky_uid_to_name(uid)
    num = tonumber(conky_parse(uid))
    name = conky_parse('${exec id -nu ${num}}')
    return name

but this never works either as I can't get the parser to see my variable. How do I send a variable to the name variable to be properly parsed by Conky? I'm sure there's an easier way of doing this, but I'm not finding many lua examples and their docs are severely lacking.

1 Answer 1


If you are not using a template, then you can use eval to re-parse the exec after the top part has provided its result:

${eval $${exec id -nu ${top uid 1}}}

Note the $$ to stop the exec being run, but the ${ for top to allow it to run.

  • This works great! Curious why it won't work in a template, though. Aug 27, 2021 at 15:59
  • I've never managed to understand exactly how conky parses complex templates mixed with exec and eval. I only use them for simple cases, and for anything complicated it is simpler to write an awk script or similar to munge the conkyrc before the start.
    – meuh
    Aug 27, 2021 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .