I have ${top cpu 1}
that show me for example 13.34
. Is it possible to round this to 13
?
1 Answer
You can write a small bit of lua
code to do this for you. For example, in your ~/.conkyrc
:
conky.config = {
lua_load = '/tmp/mylua.lua',
};
conky.text = [[
${lua conky_myfun ${top cpu 1}}
]]
and in file /tmp/mylua.lua
function conky_myfun(arg)
local n = conky_parse(arg)
return math.floor(tonumber(n)+.5)
end
This calls conky_myfun
with the given arg. The function
evaluates the arg to get the value, it is converted to a number,
and rounded to the nearest integer.
execi
to do something like this answer as workaround.