mirror of
https://github.com/vicious-widgets/vicious
synced 2023-12-14 07:13:07 +01:00
Convert tabs to spaces and better adhere to the code style practices
This commit is contained in:
parent
ce66335081
commit
25897d5982
14
helpers.lua
14
helpers.lua
|
@ -256,21 +256,21 @@ function helpers.sysctl_async(path_table, parse)
|
||||||
end,
|
end,
|
||||||
stderr = function(line)
|
stderr = function(line)
|
||||||
local messages = {
|
local messages = {
|
||||||
openbsd = {"level name .+ in (.+) is invalid"},
|
openbsd = { "level name .+ in (.+) is invalid" },
|
||||||
linux = {"cannot stat /proc/sys/(.+):",
|
linux = { "cannot stat /proc/sys/(.+):",
|
||||||
"permission denied on key '(.+)'"},
|
"permission denied on key '(.+)'" },
|
||||||
freebsd = {"unknown oid '(.+)'"}
|
freebsd = { "unknown oid '(.+)'" }
|
||||||
}
|
}
|
||||||
|
|
||||||
for i=1,#messages[helpers.getos()] do
|
for _, error_message in ipairs(messages[helpers.getos()]) do
|
||||||
local key = line:match(messages[helpers.getos()][i])
|
local key = line:match(error_message)
|
||||||
if key then
|
if key then
|
||||||
key = key:gsub("/", ".")
|
key = key:gsub("/", ".")
|
||||||
ret[key] = "N/A"
|
ret[key] = "N/A"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
output_done = function() parse(ret) end
|
output_done = function () parse(ret) end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
local table = {
|
||||||
|
insert = table.insert
|
||||||
|
}
|
||||||
|
|
||||||
local math = {
|
local math = {
|
||||||
floor = math.floor,
|
floor = math.floor,
|
||||||
modf = math.modf
|
modf = math.modf
|
||||||
|
@ -43,7 +47,7 @@ function bat_openbsd.async(format, warg, callback)
|
||||||
for _, v in pairs(fields) do table.insert(sysctl_args, v) end
|
for _, v in pairs(fields) do table.insert(sysctl_args, v) end
|
||||||
|
|
||||||
local battery = {}
|
local battery = {}
|
||||||
helpers.sysctl_async(sysctl_args, function(ret)
|
helpers.sysctl_async(sysctl_args, function (ret)
|
||||||
for k, v in pairs(fields) do
|
for k, v in pairs(fields) do
|
||||||
-- discard the description that comes after the values
|
-- discard the description that comes after the values
|
||||||
battery[k] = tonumber(ret[v]:match("(.-) "))
|
battery[k] = tonumber(ret[v]:match("(.-) "))
|
||||||
|
|
Loading…
Reference in a new issue