[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 tonumber = tonumber
|
||||||
local string = { format = string.format, gmatch = string.gmatch }
|
local string = { format = string.format, gmatch = string.gmatch }
|
||||||
local io = { popen = io.popen }
|
local io = { popen = io.popen }
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor, modf = math.modf }
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
local string = {
|
|
||||||
gmatch = string.gmatch,
|
|
||||||
match = string.match,
|
|
||||||
format = string.format
|
|
||||||
}
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
local bat_openbsd = {}
|
local bat_openbsd = {}
|
||||||
|
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
|
@ -44,8 +39,8 @@ local function worker(format, warg)
|
||||||
time = "∞"
|
time = "∞"
|
||||||
else
|
else
|
||||||
local raw_time = bat_info.watthour3 / bat_info.power0
|
local raw_time = bat_info.watthour3 / bat_info.power0
|
||||||
local hours = math.floor(raw_time)
|
local hours, hour_fraction = math.modf(raw_time)
|
||||||
local minutes = raw_time % 1
|
local minutes = math.floor(60 * hour_fraction)
|
||||||
time = string.format("%d:%0.2d", hours, minutes)
|
time = string.format("%d:%0.2d", hours, minutes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue