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