]> git.sur5r.net Git - i3/i3status/commitdiff
battery info: output errors in JSON in every case
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 15 May 2012 10:30:23 +0000 (12:30 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 15 May 2012 10:30:23 +0000 (12:30 +0200)
This hopefully fixes http://bugs.i3wm.org/707

src/print_battery_info.c

index 29d703cdffab5d6117293f930d943e4abeedad37..1c000e1ea0a9a49c139f0be67e612cbbb00311d8 100644 (file)
@@ -92,8 +92,10 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char
                 }
         }
 
-        if ((full_design == 1) || (remaining == -1))
+        if ((full_design == -1) || (remaining == -1)) {
+                OUTPUT_FULL_TEXT("No battery");
                 return;
+        }
 
         (void)snprintf(statusbuf, sizeof(statusbuf), "%s",
                         (status == CS_CHARGING ? "CHR" :
@@ -134,19 +136,19 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char
         size_t sysctl_size = sizeof(sysctl_rslt);
 
         if (sysctlbyname(BATT_LIFE, &sysctl_rslt, &sysctl_size, NULL, 0) != 0) {
-                printf("No battery");
+                OUTPUT_FULL_TEXT("No battery");
                 return;
         }
 
         present_rate = sysctl_rslt;
         if (sysctlbyname(BATT_TIME, &sysctl_rslt, &sysctl_size, NULL, 0) != 0) {
-                printf("No battery");
+                OUTPUT_FULL_TEXT("No battery");
                 return;
         }
 
         remaining = sysctl_rslt;
         if (sysctlbyname(BATT_STATE, &sysctl_rslt, &sysctl_size, NULL,0) != 0) {
-                printf("No battery");
+                OUTPUT_FULL_TEXT("No battery");
                 return;
         }