From c392152d3aa674a62c07c109b92e68c30b4f3c38 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Mon, 8 Jun 2009 21:15:18 +0200 Subject: [PATCH] extra displayoptions for battery_short and make sure full isn't handled as unknown --- ChangeLog | 6 ++++++ doc/variables.xml | 5 +++-- src/linux.c | 14 +++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0b593f8..43783893 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-06-08 + * $battery_short can now also display F (full), N (not present),E (empty), + U (unknown) + * Fix problem that $battery and $battery_short displayed unknown on some + systems when the battery wasn't unknown but full + 2009-06-06 * Add support for membar,swapbar,cpubar,fs_bar,fs_bar_free,battery_bar, execbar,execibar,lua_bar,entropy_bar,mpd_bar,apcupsd_loadbar and diff --git a/doc/variables.xml b/doc/variables.xml index c5ed419e..7c50e74e 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -433,8 +433,9 @@ Battery status and remaining percentage capacity of ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0). This mode display a short - status, which means that C is displayed instead of charging - and D is displayed instead of discharging. + status, which means that C is displayed instead of charging, + D for discharging, F for full, N for not present, E for empty + and U for unknown. diff --git a/src/linux.c b/src/linux.c index 74fceb35..6069b2a2 100644 --- a/src/linux.c +++ b/src/linux.c @@ -1643,7 +1643,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item) } /* charged */ /* thanks to Lukas Zapletal */ - else if (strncmp(charging_state, "Charged", 64) == 0) { + else if (strncmp(charging_state, "Charged", 64) == 0 || strncmp(charging_state, "Full", 64) == 0) { /* Below happens with the second battery on my X40, * when the second one is empty and the first one * being charged. */ @@ -1849,6 +1849,18 @@ void get_battery_short_status(char *buffer, unsigned int n, const char *bat) } else if (0 == strncmp("discharging", buffer, 11)) { buffer[0] = 'D'; memmove(buffer + 1, buffer + 11, n - 11); + } else if (0 == strncmp("charged", buffer, 7)) { + buffer[0] = 'F'; + memmove(buffer + 1, buffer + 7, n - 7); + } else if (0 == strncmp("not present", buffer, 11)) { + buffer[0] = 'N'; + memmove(buffer + 1, buffer + 11, n - 11); + } else if (0 == strncmp("empty", buffer, 5)) { + buffer[0] = 'E'; + memmove(buffer + 1, buffer + 5, n - 5); + } else if (0 != strncmp("AC", buffer, 2)) { + buffer[0] = 'U'; + memmove(buffer + 1, buffer + 11, n - 11); } }