From af4e85f99d0ac63127f19640ef47d768d7bed7cd Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 4 Oct 2009 16:26:34 +0200 Subject: bat: added a handler for incompetent users A lot of people expect widgets like this one to auto-magically work, and somehow don't understand that *they* need to make sure there is a source of information. Is ACPI module loaded? Is battery info exposed in the same place that widget expects by default? You need to answer those questions before loading the widget and sending me "bug" reports. --- bat.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bat.lua') diff --git a/bat.lua b/bat.lua index 9a45afe..09f1366 100644 --- a/bat.lua +++ b/bat.lua @@ -32,10 +32,12 @@ local function worker(format, batid) -- Get /proc/acpi/battery info local f = io.open("/proc/acpi/battery/"..batid.."/info") + -- Handler for incompetent users + if not f then return {"/", "/", "/"} end local infofile = f:read("*all") f:close() - -- Check if the file wasn't found or the battery isn't present + -- Check if the battery is present if infofile == nil or string.find(infofile, "present:[%s]+no") then return {"/", "/", "/"} end -- cgit v1.2.3