[bat_openbsd] Fix compatibility with Lua 5.3 and remaining time display (#78)
Also remove duplicated environment
This commit is contained in:
parent
d9c4714731
commit
3f42e7aeb9
|
@ -3,14 +3,9 @@ local setmetatable = setmetatable
|
|||
local tonumber = tonumber
|
||||
local string = { format = string.format, gmatch = string.gmatch }
|
||||
local io = { popen = io.popen }
|
||||
local math = { floor = math.floor }
|
||||
local helpers = require("vicious.helpers")
|
||||
local string = {
|
||||
gmatch = string.gmatch,
|
||||
match = string.match,
|
||||
format = string.format
|
||||
}
|
||||
local math = { floor = math.floor, modf = math.modf }
|
||||
-- }}}
|
||||
|
||||
local bat_openbsd = {}
|
||||
|
||||
local function worker(format, warg)
|
||||
|
@ -43,10 +38,10 @@ local function worker(format, warg)
|
|||
if tonumber(bat_info.power0) < 1 then
|
||||
time = "∞"
|
||||
else
|
||||
local raw_time = bat_info.watthour3 / bat_info.power0
|
||||
local hours = math.floor(raw_time)
|
||||
local minutes = raw_time % 1
|
||||
time = string.format("%d:%0.2d", hours, minutes)
|
||||
local raw_time = bat_info.watthour3 / bat_info.power0
|
||||
local hours, hour_fraction = math.modf(raw_time)
|
||||
local minutes = math.floor(60 * hour_fraction)
|
||||
time = string.format("%d:%0.2d", hours, minutes)
|
||||
end
|
||||
|
||||
-- calculate wear level from (last full / design) capacity
|
||||
|
|
Loading…
Reference in New Issue