0

This question here seems to tangentially touch upon it but I cannot get it to work. Here is my LUA file:

function conky_myeval()
   local myTable = { " Old London :normal:size=7", "Ethnocentric :normal:size=7"}
   var1 = myTable[ math.random( #myTable)] 
   return var1
end

and the related conky part:

${font ${lua conky_myeval}} Hello World!

Thank you for any assistance and I apologize if this has been asked before; The most similar I found I posted above.

  • what's the problem with that? are there any error messages? how does the behaviour differ from what you expect? the Lua code is syntactically correct. I don't know conky. the only thing that looks a bit off are the spaces befor and after the font names. I haven't seen this in the documentation or any other example. but maybe that's ignored. – Piglet Feb 10 '22 at 08:50
  • The problem is with Conky, I think. It just displays "Hello World!" as the default font. So the **${font}** command is clearly running, but it's not taking the input of **conky_myeval** which would be **Old London** etc. – DecarbonatedOdes Feb 10 '22 at 16:20

1 Answers1

1

I've found it easier to have a lua script pass conky a string that can be parsed by a lua_parse object that then generates the intended object rather than trying to pass a value to the intended object.

In the case of random fonts, I'd do something like the following, which worked when tested.

Lua file:

function conky_myfont()
   local myTable = {"DejaVu Serif:normal:size=12", "MuseJazz Text:normal:size=12"}
   var1 = myTable[ math.random( #myTable)] 
   return "${font "..var1.."}"
end

Conky part:

${lua_parse conky_myfont}Hello World!${font}
David Yockey
  • 595
  • 3
  • 11