aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-01-01 05:01:57 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-01-01 05:01:57 +0100
commit047db4eb8c83e1d70f92dfe240197a1bd88051c6 (patch)
tree44c9d58cc9ee48a57da42aa4fd546abb51af3588
parentae0c29559c1ef04118445d4c163ca8fd37942fc9 (diff)
downloaddesktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.tar.gz
desktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.tar.xz
desktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.zip
Fix battery reporting on Dells
-rw-r--r--wmstatus.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/wmstatus.c b/wmstatus.c
index 4f1c434..23521b5 100644
--- a/wmstatus.c
+++ b/wmstatus.c
@@ -1315,8 +1315,12 @@ read_battery_status (int dir, struct error **e)
|| (charge_full = read_number (dir, "charge_full", &error), error))
error_propagate (e, error);
else
- result = xstrdup_printf ("%s (%u%%)",
- status, (unsigned) (charge_now / charge_full * 100 + 0.5));
+ {
+ // Dell is being unreasonable and seems to set charge_now
+ // to charge_full_design when the battery is fully charged
+ unsigned percentage = charge_now / charge_full * 100 + 0.5;
+ result = xstrdup_printf ("%s (%u%%)", status, MIN (percentage, 100));
+ }
free (status);
return result;