Revert bat_openbsd since the change is unnecessary
This commit is contained in:
parent
83efd26802
commit
d533a1d190
|
@ -34,17 +34,18 @@ local STATES = { [0] = "↯", -- not charging
|
||||||
|
|
||||||
return helpers.setasyncall{
|
return helpers.setasyncall{
|
||||||
async = function (format, warg, callback)
|
async = function (format, warg, callback)
|
||||||
if warg == nil then warg = 'bat0' end
|
local filter = "hw.sensors.acpi" .. (warg or "bat0")
|
||||||
local pattern = ("hw.sensors.acpi%s.(%S+)=(%S+)"):format(warg)
|
local pattern = filter .. ".(%S+)=(%S+)"
|
||||||
|
|
||||||
spawn.async(
|
|
||||||
"sysctl -a",
|
|
||||||
function (stdout, stderr, exitreason, exitcode)
|
|
||||||
local bat_info = {}
|
local bat_info = {}
|
||||||
for key, value in stdout:gmatch(pattern) do
|
|
||||||
|
spawn.with_line_callback_with_shell(
|
||||||
|
("sysctl -a | grep '^%s'"):format(filter),
|
||||||
|
{ stdout = function (line)
|
||||||
|
for key, value in line:gmatch(pattern) do
|
||||||
bat_info[key] = value
|
bat_info[key] = value
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
|
output_done = function ()
|
||||||
-- current state
|
-- current state
|
||||||
local state = STATES[tonumber(bat_info.raw0)]
|
local state = STATES[tonumber(bat_info.raw0)]
|
||||||
|
|
||||||
|
@ -52,8 +53,10 @@ return helpers.setasyncall{
|
||||||
local percent = tonumber(
|
local percent = tonumber(
|
||||||
bat_info.watthour3 / bat_info.watthour0 * 100)
|
bat_info.watthour3 / bat_info.watthour0 * 100)
|
||||||
|
|
||||||
local time = "∞"
|
local time
|
||||||
if tonumber(bat_info.power0) >= 1 then
|
if tonumber(bat_info.power0) < 1 then
|
||||||
|
time = "∞"
|
||||||
|
else
|
||||||
local raw_time = bat_info.watthour3 / bat_info.power0
|
local raw_time = bat_info.watthour3 / bat_info.power0
|
||||||
local hours, hour_fraction = math.modf(raw_time)
|
local hours, hour_fraction = math.modf(raw_time)
|
||||||
local minutes = math.floor(60 * hour_fraction)
|
local minutes = math.floor(60 * hour_fraction)
|
||||||
|
@ -78,5 +81,5 @@ return helpers.setasyncall{
|
||||||
-- * wear level (in percent)
|
-- * wear level (in percent)
|
||||||
-- * present_rate (in Watts)
|
-- * present_rate (in Watts)
|
||||||
callback{state, percent, time, wear, rate}
|
callback{state, percent, time, wear, rate}
|
||||||
end)
|
end })
|
||||||
end }
|
end }
|
||||||
|
|
Loading…
Reference in New Issue