awesomewm/wrapper/backlight.lua

37 lines
605 B
Lua
Raw Normal View History

2021-08-01 07:24:26 -07:00
local backlight = {}
backlight.hooks = {}
backlight.add_hook = function(callback)
backlight.hooks[#backlight.hooks + 1] = callback
end
backlight.exec_hooks = function()
backlight.read(function(status)
for i=1, #backlight.hooks do
backlight.hooks[i](status)
end
end)
end
backlight.read = function(callback)
bin.backlight.get(
function(stdout, stderr, exitreason, exitcode)
callback(tonumber(stdout))
end
)
end
backlight.up = function()
bin.backlight.up()
backlight.exec_hooks()
end
backlight.down = function()
bin.backlight.down()
backlight.exec_hooks()
end
return backlight