lxde / lxpanel

Other
52 stars 38 forks source link

Add option to thermal plugin to show first decimal place #66

Open Gordin508 opened 3 months ago

Gordin508 commented 3 months ago

The major point of this PR is to add an option to show a single decimal place in the temperature display. While most sensors only yield integer values, there are some which at least can supply 0.5 increments.

Current Behavior

Updated Behavior

Minor Addition: Support for OTHER input files

This PR also adds logic to use an arbitrary file as sensor (called raw in the code), which works the same as reading a temperature from a file under /sys/class/thermal. Reading from arbitrary locations was already possible before by exploiting the logic, as the checks would treat a folder at an unexpected path as if it were under /proc/. You could previously e.g. create a file under /home/alice/mysensors/temperature with this content:

temperature: 80 C

and point the plugin to /home/alice/mysensors to read this 80 C value. The new behavior is to first check for the /sys/ and /proc prefixes explicitly, and if none applies, treat the passed path as a filepath with a format as used in /sys/class/thermal. You can e.g. create the file /home/alice/outside_temp with the content

25300

and pass the full path /home/alice/outside_temp to read this as 25.3 C. This can be paired with a background script to e.g. query non-internal sensors, web-APIs etc.

Minor Addition: Disambiguate temperatures from error code

Currently, temperature-returning functions return -1 upon error. While internal sensors will usually not encounter negative temperatures, this may be ambiguous now that we support OTHER files. Therefore the new error code is set to a number below absolute zero.