commit 6f66af17e15ed657e5ae2d1d1c951ea9249bbf16
parent 5fc4644c7df82545a24307f4dc1f80e3dfdfe743
Author: bsandro <email@bsandro.tech>
Date: Wed, 7 Sep 2022 23:17:11 +0300
Do not display remaining charge/discharge time if the battery is at 100% and plugged in.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dwmstatus.c b/dwmstatus.c
@@ -166,7 +166,7 @@ getbattery(void)
double consumption = -1.0;
char charger_state = ' ';
double percentage = 0.0;
- int remaining = 0.0;
+ int remaining = 0;
mib[0] = CTL_HW;
mib[1] = HW_SENSORS;
@@ -208,8 +208,10 @@ getbattery(void)
remaining = (full_charge - cur_charge) / consumption * 60.0;
}
- if (remaining < 60.0) {
+ if (remaining < 60 && remaining > 0) {
return smprintf("%.1f%%%c(%dm)", percentage, charger_state, remaining);
+ } else if (remaining == 0) {
+ return smprintf("%.1f%%%c", percentage, charger_state);
} else {
return smprintf("%.1f%%%c(%dh%dm)", percentage, charger_state, remaining / 60, remaining % 60);
}