varingst / awesome-conky

Make AwesomeWM 4.0 widgets displaying system information from conky
29 stars 1 forks source link

Problem with example in README instructing updater function #3

Closed doronbehar closed 7 years ago

doronbehar commented 7 years ago

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..

varingst commented 7 years ago

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

doronbehar commented 7 years ago

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?

varingst commented 7 years ago

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.

doronbehar commented 7 years ago

I copied exactly what was written on the README.md, as is.

varingst commented 7 years ago

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.

doronbehar commented 7 years ago

OK, I guess I have to dive deeper into the actual code to get my head around it.

Thanks :)