summaryrefslogtreecommitdiff
path: root/src/print_battery_info.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2014-05-31 14:01:18 +0200
committerMichael Stapelberg <michael@stapelberg.de>2014-05-31 14:01:18 +0200
commit2158128ea0343f7e1b736f141289a71ef51797c1 (patch)
tree19c5c1709152a029eac6e8172b595eee3f722080 /src/print_battery_info.c
parent653505a3bbaad141d9fb94458e2ffffe312a8e58 (diff)
Use the absolute values for (dis)charging rates
Apparently some notebooks report a negative current, whereas most don’t. fixes #1249
Diffstat (limited to 'src/print_battery_info.c')
-rw-r--r--src/print_battery_info.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c
index 7277765..102522b 100644
--- a/src/print_battery_info.c
+++ b/src/print_battery_info.c
@@ -89,15 +89,15 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char
remaining = atoi(walk+1);
}
else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW"))
- present_rate = atoi(walk+1);
+ present_rate = abs(atoi(walk+1));
else if (BEGINS_WITH(last, "POWER_SUPPLY_VOLTAGE_NOW"))
- voltage = atoi(walk+1);
+ voltage = abs(atoi(walk+1));
/* on some systems POWER_SUPPLY_POWER_NOW does not exist, but actually
* it is the same as POWER_SUPPLY_CURRENT_NOW but with μWh as
* unit instead of μAh. We will calculate it as we need it
* later. */
else if (BEGINS_WITH(last, "POWER_SUPPLY_POWER_NOW"))
- present_rate = atoi(walk+1);
+ present_rate = abs(atoi(walk+1));
else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging"))
status = CS_CHARGING;
else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))