batsys: don't return 0 if only rate is missing
This commit is contained in:
parent
8e21d264d2
commit
6fadee6fb5
10
batsys.lua
10
batsys.lua
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue