dotfiles/.config/awesome/contrib/xbacklight.lua

26 lines
711 B
Lua
Raw Normal View History

2019-10-12 09:49:51 +02:00
local tonumber = tonumber
local string = { match = string.match }
local table = { concat = table.concat }
local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- xbacklight: provides backlight level
-- vicious.contrib.xbacklight
local xbacklight = {}
local function parse(stdout, stderr, exitreason, exitcode)
return math.floor(tonumber(stdout))
end
function xbacklight.async(format, warg, callback)
if not warg then return callback{} end
if type(warg) ~= "table" then warg = { warg } end
spawn.easy_async("xbacklight" .. table.concat(warg, " "),
function (...) callback(parse(...)) end)
end
-- }}}
return helpers.setasyncall(xbacklight)