简体   繁体   English

我如何通过 LUA 在 Conky 中随机循环 fonts?

[英]How do I cycle through random fonts in Conky via LUA?

This question here seems to tangentially touch upon it but I cannot get it to work. 这里的这个问题似乎切线地触及了它,但我无法让它发挥作用。 Here is my LUA file:这是我的 LUA 文件:

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:和相关的conky部分:

${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.我发现最相似的是我在上面发布的。

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.我发现让 lua 脚本传递 conky 字符串更容易,该字符串可以由lua_parse object 解析,然后生成预期的 object 而不是尝试将值传递给预期的 object。

In the case of random fonts, I'd do something like the following, which worked when tested.在随机 fonts 的情况下,我会做类似下面的事情,这在测试时有效。

Lua file: Lua 档案:

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}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM