2022-07-16 16:06:02 -07:00
|
|
|
local backlight = {}
|
|
|
|
|
2022-11-05 11:31:12 -07:00
|
|
|
backlight.get = function(callback)
|
2022-07-16 16:06:02 -07:00
|
|
|
awful.spawn.easy_async(
|
2023-08-23 08:09:31 -07:00
|
|
|
"xbacklight -get",
|
2022-07-16 16:06:02 -07:00
|
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
|
|
callback(tonumber(stdout))
|
|
|
|
end
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
backlight.set = function(value)
|
2023-08-23 08:09:31 -07:00
|
|
|
awful.spawn("xbacklight -set " .. value, false)
|
2022-07-16 16:06:02 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
backlight.watch = function(timeout, callback, widget)
|
|
|
|
awful.widget.watch(
|
2023-08-23 08:09:31 -07:00
|
|
|
"xbacklight -get",
|
2022-07-16 16:06:02 -07:00
|
|
|
timeout,
|
|
|
|
callback,
|
|
|
|
widget
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2022-11-05 11:31:12 -07:00
|
|
|
backlight.backlight_up = function(value)
|
|
|
|
awful.spawn.easy_async(
|
2023-08-23 08:09:31 -07:00
|
|
|
"xbacklight -inc " .. value,
|
2022-11-05 11:31:12 -07:00
|
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
|
|
awesome.emit_signal("module::backlight:update_read")
|
|
|
|
end
|
|
|
|
)
|
2022-07-16 16:06:02 -07:00
|
|
|
end
|
|
|
|
|
2022-11-05 11:31:12 -07:00
|
|
|
backlight.backlight_down = function(value)
|
|
|
|
awful.spawn.easy_async(
|
2023-08-23 08:09:31 -07:00
|
|
|
"xbacklight -dec " .. value,
|
2022-11-05 11:31:12 -07:00
|
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
|
|
awesome.emit_signal("module::backlight:update_read")
|
|
|
|
end
|
|
|
|
)
|
2022-07-16 16:06:02 -07:00
|
|
|
end
|
|
|
|
|
2022-11-05 11:31:12 -07:00
|
|
|
awesome.connect_signal("module::backlight:update_read",
|
|
|
|
function()
|
|
|
|
backlight.get(
|
|
|
|
function(value)
|
|
|
|
awesome.emit_signal(
|
|
|
|
"module::backlight:update",
|
|
|
|
value
|
|
|
|
)
|
|
|
|
end
|
|
|
|
)
|
|
|
|
end
|
|
|
|
)
|
2022-07-16 16:06:02 -07:00
|
|
|
|
|
|
|
|
|
|
|
return backlight
|