diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-01 05:01:57 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-01 05:01:57 +0100 |
commit | 047db4eb8c83e1d70f92dfe240197a1bd88051c6 (patch) | |
tree | 44c9d58cc9ee48a57da42aa4fd546abb51af3588 | |
parent | ae0c29559c1ef04118445d4c163ca8fd37942fc9 (diff) | |
download | desktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.tar.gz desktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.tar.xz desktop-tools-047db4eb8c83e1d70f92dfe240197a1bd88051c6.zip |
Fix battery reporting on Dells
-rw-r--r-- | wmstatus.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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; |