extra displayoptions for battery_short and make sure full isn't handled as unknown
authorNikolas Garofil <garo@dunaldi.garofil.be>
Mon, 8 Jun 2009 19:15:18 +0000 (21:15 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Mon, 8 Jun 2009 19:15:18 +0000 (21:15 +0200)
ChangeLog
doc/variables.xml
src/linux.c

index a0b593f..4378389 100644 (file)
--- 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
index c5ed419..7c50e74 100644 (file)
         <listitem>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. 
         <para /></listitem>
     </varlistentry>
     <varlistentry>
index 74fceb3..6069b2a 100644 (file)
@@ -1643,7 +1643,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
                }
                /* charged */
                /* thanks to Lukas Zapletal <lzap@seznam.cz> */
-               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);
        }
 }