1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +00:00

Added support for POWER_SUPPLY_POWER_NOW In Linux, apparently POWER_SUPPLY_CURRENT_NOW was deprecated and replaced by POWER_SUPPLY_POWER_NOW. In my system, ever since kernel 2.6.36.1 battery lifetime showed "unknown" in conky. Check http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532000.

Signed-off-by: Pavel Labath <pavelo@centrum.sk>
This commit is contained in:
Tiago Vale 2010-12-04 20:45:34 +00:00 committed by Pavel Labath
parent 29ef75083a
commit c5d065d119

View File

@ -1588,6 +1588,12 @@ present voltage: 16608 mV
On some systems POWER_SUPPLY_ENERGY_* is replaced by POWER_SUPPLY_CHARGE_*
*/
/* Tiago Marques Vale <tiagomarquesvale@gmail.com>
Regarding the comment above, since kernel 2.6.36.1 I have
POWER_SUPPLY_POWER_NOW instead of POWER_SUPPLY_CURRENT_NOW
See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532000
*/
#define SYSFS_BATTERY_BASE_PATH "/sys/class/power_supply"
#define ACPI_BATTERY_BASE_PATH "/proc/acpi/battery"
#define APM_PATH "/proc/apm"
@ -1709,6 +1715,8 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
* tradition! */
else if (strncmp(buf, "POWER_SUPPLY_CURRENT_NOW=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CURRENT_NOW=%d", &present_rate);
else if (strncmp(buf, "POWER_SUPPLY_POWER_NOW=", 23) == 0)
sscanf(buf, "POWER_SUPPLY_POWER_NOW=%d", &present_rate);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=", 25) == 0)