tbatt: show when a battery is absent - spoon - dwm status utility (2f30 fork) (HTM) git clone git://src.adamsgaard.dk/spoon (DIR) Log (DIR) Files (DIR) Refs (DIR) LICENSE --- (DIR) commit 8829486d5587ca59a8609dcd865acb5e84a8dbcf (DIR) parent dd94bee628add1dad6d41fc2223a40b87311d871 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Sun, 1 Jul 2018 11:41:36 +0200 batt: show when a battery is absent Diffstat: M batt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- (DIR) diff --git a/batt.c b/batt.c t@@ -10,7 +10,7 @@ char *crit[] = { }; void -battprint(char *buf, size_t len, int acon , int life) +battprint(char *buf, size_t len, int acon, int life) { char c; static int frame = 0; t@@ -56,7 +56,11 @@ battread(void *arg, char *buf, size_t len) return -1; } close(fd); - battprint(buf, len, info.ac_state == APM_AC_ON, info.battery_life); + + if (info.battery_state == APM_BATTERY_ABSENT) + snprintf(buf, len, "[no batt]"); + else + battprint(buf, len, info.ac_state == APM_AC_ON, info.battery_life); return 0; } #elif __linux__