Problem with example in README instructing updater function
doronbehar opened this issue · 6 comments
O.K, I've managed to create some widgets and they looks wonderful.
I wanted to use updater =
and change the background color of the CPU widget when it's value goes above 80, as instructed in the example.
The problem is I get the error:
.../rc.lua:153: attempt to compare number with nil
Pointing me to the line where I make the comparison of tonumber(conky_update)
with 80
.
Is there any workaround? This feature could come up very nicely in my configuration..
tonumber()
returns nil if it can't parse a number from the string you pass it, in this case conky_update
you can guard against this by doing if (tonumber(conky_update) or 0) > 80 then
But if eventually conky_update
is nil all the time, than I will never have a red background for the widget even when it's value is above 80
. Am I right?
That stops awesome from printing an error whenever the comparison fails. But if conky_update really is nil, set_text
will fail as well. I'd rather guess that conky_update
is something that tonumber
can't parse to a number. You need to show your actual configuration for me to be able to help.
I copied exactly what was written on the README.md
, as is.
The examples are for showcasing functionality and to serve as a starting point or inspiration for your own code, not to be copied verbatim. There's no guarantee that the ${hwmon}
variables will be the right ones for your system, and "My Neat Font"
will almost certainly not be an actual font you have installed :o)
I went over the ${cpu}
variables before heading out last weekend, they should be working now at least.
OK, I guess I have to dive deeper into the actual code to get my head around it.
Thanks :)