summaryrefslogtreecommitdiff
path: root/src/print_battery_info.c
diff options
context:
space:
mode:
authorJulien Lequertier <git@avrelaun.com>2013-02-10 17:59:37 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-02-14 19:35:15 +0100
commit67c2c1a7ead6bcdcd07080e581013fa7a0b58b6f (patch)
treecdda81830825842127c90df4b196b85c86d9f4f0 /src/print_battery_info.c
parent8c273e54b867aeedcd1eadfbd6f4e4fad3690f74 (diff)
Added option to show battery capacity without decimals
Diffstat (limited to 'src/print_battery_info.c')
-rw-r--r--src/print_battery_info.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c
index 1545609..d4b091b 100644
--- a/src/print_battery_info.c
+++ b/src/print_battery_info.c
@@ -30,7 +30,7 @@
* worn off your battery is.
*
*/
-void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char *path, const char *format, int low_threshold, char *threshold_type, bool last_full_capacity) {
+void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char *path, const char *format, int low_threshold, char *threshold_type, bool last_full_capacity, bool integer_battery_capacity) {
time_t empty_time;
struct tm *empty_tm;
char buf[1024];
@@ -130,7 +130,11 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char
(void)snprintf(statusbuf, sizeof(statusbuf), "%s", BATT_STATUS_NAME(status));
float percentage_remaining = (((float)remaining / (float)full_design) * 100);
- (void)snprintf(percentagebuf, sizeof(percentagebuf), "%.02f%%", percentage_remaining);
+ if (integer_battery_capacity) {
+ (void)snprintf(percentagebuf, sizeof(percentagebuf), "%.00f%%", percentage_remaining);
+ } else {
+ (void)snprintf(percentagebuf, sizeof(percentagebuf), "%.02f%%", percentage_remaining);
+ }
if (present_rate > 0) {
float remaining_time;