From 763cfb7384fe3432c1e74cea12aa3ddc9a66d7c7 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Mon, 25 Jul 2022 22:39:33 +0200 Subject: [PATCH] Change battery status --- dwmstatus.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dwmstatus.c b/dwmstatus.c index 1f7eab7..1b63143 100644 --- a/dwmstatus.c +++ b/dwmstatus.c @@ -116,8 +116,9 @@ readfile(char *base, char *file) char * getbattery(char *base) { - char *co, status; - int descap, remcap; + char *co; + char *status; + int descap, remcap; descap = -1; remcap = -1; @@ -151,17 +152,17 @@ getbattery(char *base) co = readfile(base, "status"); if (!strncmp(co, "Discharging", 11)) { - status = '-'; + status = "🔋"; } else if(!strncmp(co, "Charging", 8)) { - status = '+'; + status = "🔌"; } else { - status = '?'; + status = "🔋?"; } if (remcap < 0 || descap < 0) return smprintf("invalid"); - return smprintf("%.0f%%%c", ((float)remcap / (float)descap) * 100, status); + return smprintf("%s %.0f%%", status, ((float)remcap / (float)descap) * 100); } char * @@ -195,7 +196,7 @@ main(void) t0 = gettemperature("/sys/class//hwmon/hwmon1", "temp1_input"); bat = getbattery("/sys/class/power_supply/BAT0"); - status = smprintf("🔋 %s 🌡 %s 📈 %s 📅 %s", + status = smprintf("%s 🌡 %s 📈 %s 📅 %s", bat, t0, avgs, tmbln); setstatus(status);