The Sin of Hardcoding

I decided to try to keep an eye on the temperature on my laptop. Some digging around turned up the statusd_laptopstatus.lua script in the ion3-scripts package which seemed exactly like what I wanted.  So I copied it out of the example directory into my .ion3, and the cfg_statusbar.lua file as well and tweaked it up according to directions and a simple F12 session/restart later, voila:

/usr/lib/ion3/ion-statusd: /usr/share/ion3/statusd_laptopstatus.lua:96: attempt to index local 'file' (a nil value)

Ooops.  So I actually learned to read enough lua to discover that the problem was that whatever file was supposed to be ac_state wasn’t there.  None of the four choices:
ac_state = {"/proc/acpi/ac_adapter/AC/state",
"/proc/acpi/ac_adapter/ACAD/state",
"/proc/acpi/ac_adapter/ADP0/state",
"/proc/acpi/ac_adapter/ADP1/state"},

So then I pawed through my /proc tree and found the closest match, /proc/acpi/ac_adapter/AC0/state which, great. So my fix was to re-hardcode by adding a 0 to the AC in the first file pattern. Yes, yes. I’m a bad person. Another hardcoded tweak to poll temperature info from
“/proc/acpi/thermal_zone/TZ00/temperature” as opposed to any of the other choices and, voila, original yak shaved.

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...