From f8be2d1b81454be9f3205f3c908ea11e23f9c1e9 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 25 Jul 2009 21:32:38 +0200 Subject: Return "no battery" instead of dying if a battery wasn’t found (Thanks Mirko) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/get_battery_info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/get_battery_info.c') diff --git a/src/get_battery_info.c b/src/get_battery_info.c index 8ac7743..41f2ff3 100644 --- a/src/get_battery_info.c +++ b/src/get_battery_info.c @@ -26,7 +26,8 @@ const char *get_battery_info(struct battery *bat) { charging_status_t status = CS_DISCHARGING; #if defined(LINUX) - slurp(bat->path, buf, sizeof(buf)); + if (!slurp(bat->path, buf, sizeof(buf))) + return "No battery"; for (walk = buf, last = buf; (walk-buf) < 1024; walk++) { if (*walk == '\n') { -- cgit v1.2.3