59 lines
1.0 KiB
Lua
Executable File
59 lines
1.0 KiB
Lua
Executable File
local backlight = {}
|
|
|
|
backlight.get = function(callback)
|
|
awful.spawn.easy_async(
|
|
"xbacklight -get",
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
callback(tonumber(stdout))
|
|
end
|
|
)
|
|
end
|
|
|
|
backlight.set = function(value)
|
|
awful.spawn("xbacklight -set " .. value, false)
|
|
end
|
|
|
|
backlight.watch = function(timeout, callback, widget)
|
|
awful.widget.watch(
|
|
"xbacklight -get",
|
|
timeout,
|
|
callback,
|
|
widget
|
|
)
|
|
end
|
|
|
|
|
|
backlight.backlight_up = function(value)
|
|
awful.spawn.easy_async(
|
|
"xbacklight -inc " .. value,
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
awesome.emit_signal("module::backlight:update_read")
|
|
end
|
|
)
|
|
end
|
|
|
|
backlight.backlight_down = function(value)
|
|
awful.spawn.easy_async(
|
|
"xbacklight -dec " .. value,
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
awesome.emit_signal("module::backlight:update_read")
|
|
end
|
|
)
|
|
end
|
|
|
|
awesome.connect_signal("module::backlight:update_read",
|
|
function()
|
|
backlight.get(
|
|
function(value)
|
|
awesome.emit_signal(
|
|
"module::backlight:update",
|
|
value
|
|
)
|
|
end
|
|
)
|
|
end
|
|
)
|
|
|
|
|
|
return backlight
|