commit 8829486d5587ca59a8609dcd865acb5e84a8dbcf
parent dd94bee628add1dad6d41fc2223a40b87311d871
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  1 Jul 2018 11:41:36 +0200
batt: show when a battery is absent
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/batt.c b/batt.c
@@ -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;
@@ -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__