aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 16:26:34 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 16:35:09 +0200
commitc2b68ad3e78e366e611600f54dcfa8d760ed026f (patch)
tree54bb8b2b7bd563e9a3f186c8e5a4aec2784ed461
parent191766f8fb36da478b10282de670f1224fab8ed2 (diff)
downloadvicious-legacy-c2b68ad3e78e366e611600f54dcfa8d760ed026f.tar.xz
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.
-rw-r--r--bat.lua4
-rw-r--r--thermal.lua3
2 files changed, 4 insertions, 3 deletions
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
diff --git a/thermal.lua b/thermal.lua
index 7f31a52..ab7ef89 100644
--- a/thermal.lua
+++ b/thermal.lua
@@ -17,8 +17,7 @@ module("vicious.thermal")
local function worker(format, thermal_zone)
-- Get an ACPI thermal zone
local f = io.open("/proc/acpi/thermal_zone/" .. thermal_zone .. "/temperature")
- -- Fix your ACPI setup, or find another source of temperature
- -- exposed trough /sys, if a thermal_zone can't be found
+ -- Handler for incompetent users
if not f then return {"N/A"} end
local line = f:read("*line")
f:close()