awesomewm/modules/backlight/util.lua

64 lines
1.2 KiB
Lua
Raw Normal View History

2022-07-16 16:06:02 -07:00
local backlight = {}
-- The space at the end is important!
2022-07-16 17:41:00 -07:00
local script = conf_dir .. "modules/backlight/backlight.fish"
2022-07-16 16:06:02 -07:00
script = script .. " "
2022-11-05 11:31:12 -07:00
backlight.get = function(callback)
2022-07-16 16:06:02 -07:00
awful.spawn.easy_async(
script .. "get",
function(stdout, stderr, exitreason, exitcode)
callback(tonumber(stdout))
end
)
end
backlight.set = function(value)
2022-11-05 11:31:12 -07:00
awful.spawn(script .. "set " .. value, false)
2022-07-16 16:06:02 -07:00
end
backlight.watch = function(timeout, callback, widget)
awful.widget.watch(
script .. "get",
timeout,
callback,
widget
)
end
2022-11-05 11:31:12 -07:00
backlight.backlight_up = function(value)
awful.spawn.easy_async(
script .. "up " .. value,
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(
script .. "down " .. value,
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