]> git.sur5r.net Git - i3/i3status/commitdiff
For the %percentage display of batteries, drop the leading '0' for values < 10.
authorJasper Lievisse Adriaanse <jasper@humppa.nl>
Mon, 10 Mar 2014 09:22:47 +0000 (10:22 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 12 Mar 2014 07:27:00 +0000 (08:27 +0100)
src/print_battery_info.c

index bd3ff5c63de754928a2c255a8fde0fc01954c49a..aaef46eb04d71007c04c6e760aaaaff8ecce4c00 100644 (file)
@@ -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