summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-05-15 12:30:23 +0200
committerMichael Stapelberg <michael@stapelberg.de>2012-05-15 12:30:23 +0200
commit7a77472a810b0a955f2755dd028216965b56be31 (patch)
tree1728b10209c01dcc6e39e7f8b2b3e3d09daf0ca5 /src
parent1dfb3128b061051d57261c260cb72aca3d4bcf4a (diff)
battery info: output errors in JSON in every case
This hopefully fixes http://bugs.i3wm.org/707
Diffstat (limited to 'src')
-rw-r--r--src/print_battery_info.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c
index 29d703c..1c000e1 100644
--- a/src/print_battery_info.c
+++ b/src/print_battery_info.c
@@ -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;
}