aboutsummaryrefslogtreecommitdiff
path: root/wmstatus.c
diff options
context:
space:
mode:
Diffstat (limited to 'wmstatus.c')
-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;