local backlight = {} -- The space at the end is important! local script = conf_dir .. "modules/backlight/backlight.fish" script = script .. " " 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) awful.spawn.easy_async( script .. "get", function(stdout, stderr, exitreason, exitcode) callback(tonumber(stdout)) end ) end backlight.set = function(value) awful.spawn(script .. "set " .. value, false) end backlight.watch = function(timeout, callback, widget) awful.widget.watch( script .. "get", timeout, callback, widget ) end backlight.backlight_up = function() awful.spawn(script .. "up", false) backlight.exec_hooks() end backlight.backlight_down = function() awful.spawn(script .. "down", false) backlight.exec_hooks() end backlight.redshift = function(temp) awful.spawn("redshift -O " .. tostring(temp), false) end backlight.reset_redshift = function() awful.spawn("redshift -x", false) end return backlight