From 350e9240ea792446efb22564060384f535ac4e34 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sat, 19 Nov 2011 02:20:08 +0100 Subject: [PATCH 1/2] bat: another workaround for broken ACPI implementations --- widgets/bat.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 615f9dd..2f93518 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -73,8 +73,9 @@ local function worker(format, warg) else return {state, percent, time} end - local hoursleft = math.floor(timeleft) - local minutesleft = math.floor((timeleft - hoursleft) * 60 ) + -- Calculate time (but work around broken BAT/ACPI implementations) + local hoursleft = math.min(math.floor(timeleft), 0) + local minutesleft = math.min(math.floor((timeleft - hoursleft) * 60 ), 0) time = string.format("%02d:%02d", hoursleft, minutesleft) end From cd4b04df44023f9c81885978522f337763dcf7a9 Mon Sep 17 00:00:00 2001 From: "J. Thalheim" Date: Sat, 19 Nov 2011 02:24:34 +0100 Subject: [PATCH 2/2] thermal: remove unnecessary read --- widgets/thermal.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/widgets/thermal.lua b/widgets/thermal.lua index 4d837c8..1906568 100644 --- a/widgets/thermal.lua +++ b/widgets/thermal.lua @@ -30,11 +30,12 @@ local function worker(format, warg) -- Get temperature from thermal zone local thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1]) - if thermal[zone[warg[2]].file] then + local data = thermal[zone[warg[2]].file] + if data then if zone[warg[2]].div then - return {thermal[zone[warg[2]].file] / zone[warg[2]].div} + return {data / zone[warg[2]].div} else -- /proc/acpi "temperature: N C" - return {tonumber(string.match(thermal[zone[warg[2]].file], "[%d]+"))} + return {tonumber(string.match(data, "[%d]+"))} end end