From 5c7df93baa5b2284fe93f27beca085b0aa1da8ab Mon Sep 17 00:00:00 2001 From: "J. Thalheim" Date: Sun, 20 Nov 2011 08:55:43 +0100 Subject: [PATCH] [bat] Fix bug introduced in 78e3d37fb55 Instead of setting the remaining time to reasonable values, remaining time was always set to 0, because of math.min(). --- widgets/bat.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 2f93518..f499a5e 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -74,8 +74,11 @@ local function worker(format, warg) return {state, percent, time} end -- 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) + local hoursleft, minutesleft = 0, 0 + if timeleft > 0 then + hoursleft = math.floor(timeleft) + minutesleft = math.floor((timeleft - hoursleft) * 60 ) + end time = string.format("%02d:%02d", hoursleft, minutesleft) end