aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-01-03 17:31:35 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-01-03 17:32:41 +0100
commit7c16d997581cf1d2e105da210b7619c79ded3b3f (patch)
treef1c861bdbdfe54a73c34ab29f0949fd531a39bdd
parent833ef8fe97dd4e0b14e18c523bccee6b4a52096e (diff)
downloaddesktop-tools-7c16d997581cf1d2e105da210b7619c79ded3b3f.tar.gz
desktop-tools-7c16d997581cf1d2e105da210b7619c79ded3b3f.tar.xz
desktop-tools-7c16d997581cf1d2e105da210b7619c79ded3b3f.zip
wmstatus: don't show battery percentage >= 100%
-rw-r--r--wmstatus.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/wmstatus.c b/wmstatus.c
index 6e2e582..acdfd6e 100644
--- a/wmstatus.c
+++ b/wmstatus.c
@@ -1316,10 +1316,16 @@ read_battery_status (int dir, struct error **e)
error_propagate (e, error);
else
{
+ struct str s;
+ str_init (&s);
+ str_append (&s, status);
+
// 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));
+ if (percentage < 100)
+ str_append_printf (&s, " (%u%%)", percentage);
+ result = str_steal (&s);
}
free (status);