diff options
author | Jasper Lievisse Adriaanse <jasper@humppa.nl> | 2014-03-10 10:22:47 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2014-03-12 08:27:00 +0100 |
commit | 52814295a0b3a0785631256e9e2dc6b8139e2be8 (patch) | |
tree | fd0933d1caad3992e49e7b1823b98c51d98fecf7 | |
parent | bc0bd8c9e03d92ab133f4dfae52dc202c3e0cbf6 (diff) |
For the %percentage display of batteries, drop the leading '0' for values < 10.
-rw-r--r-- | src/print_battery_info.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c index bd3ff5c..aaef46e 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -292,7 +292,8 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char } (void)snprintf(statusbuf, sizeof(statusbuf), "%s", BATT_STATUS_NAME(status)); - (void)snprintf(percentagebuf, sizeof(percentagebuf), "%02d%%", apm_info.battery_life); + /* integer_battery_capacity is implied as battery_life is already in whole numbers. */ + (void)snprintf(percentagebuf, sizeof(percentagebuf), "%.00d%%", apm_info.battery_life); if (status == CS_DISCHARGING && low_threshold > 0) { if (strncmp(threshold_type, "percentage", strlen(threshold_type)) == 0 |