batsys: don't return 0 if only rate is missing

This commit is contained in:
Adrian C. (anrxc) 2009-11-10 16:10:20 +01:00
parent 8e21d264d2
commit 6fadee6fb5
1 changed files with 5 additions and 5 deletions

View File

@ -57,14 +57,14 @@ local function worker(format, batid)
return {battery_state["Unknown\n"], 0, "N/A"} return {battery_state["Unknown\n"], 0, "N/A"}
end end
-- Get charge information
if battery.current_now then rate = battery.current_now
else return {battery_state["Unknown\n"], 0, "N/A"} end
-- Calculate percentage (but work around broken BAT/ACPI implementations) -- Calculate percentage (but work around broken BAT/ACPI implementations)
local percent = math.min(math.floor(remaining / capacity * 100), 100) local percent = math.min(math.floor(remaining / capacity * 100), 100)
-- Get charge information
if battery.current_now then rate = battery.current_now
else return {state, percent, "N/A"} end
-- Calculate remaining (charging or discharging) time -- Calculate remaining (charging or discharging) time
if state == "+"then if state == "+"then
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate) timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)