awesomewm/modules/backlight/widget.lua

62 lines
1.4 KiB
Lua
Executable File

local backlight = req_rel(..., "util")
local widget = {}
local dotgrid = require("widgets.dotgrid")
widget.dots = dotgrid:new();
widget.dots.on_color = {0.18, 0.88, 1}
widget.dots.off_color = {0.1, 0.44, 0.5}
widget.dots.spacing = beautiful.dpi(2)
widget.widget = wibox.widget {
{
widget.dots,
top = beautiful.dpi(2),
bottom = beautiful.dpi(2),
left = beautiful.dpi(2),
right = beautiful.dpi(2),
layout = wibox.container.margin,
},
layout = wibox.container.background,
}
widget.widget:connect_signal("mouse::enter", function(result)
widget.widget.bg = beautiful.color.bar.hover_bg
awesome.emit_signal("module::backlight:popup_show_stay")
end)
widget.widget:connect_signal("mouse::leave", function(result)
widget.widget.bg = beautiful.color.transparent
awesome.emit_signal("module::backlight:popup_show")
end)
widget.widget:connect_signal("button::press",
function(_, _, _, button, mods)
-- Scroll up
if (button == 4) then
backlight.backlight_up(config.backlight.scroll_step)
-- Scroll down
elseif (button == 5) then
backlight.backlight_down(config.backlight.scroll_step)
end
awesome.emit_signal("module::backlight:popup_show_stay")
end
)
awesome.connect_signal("module::backlight:update",
function(value)
widget.dots.value = value
widget.dots:emit_signal("widget::redraw_needed")
end
)
backlight.watch(
5,
function()
awesome.emit_signal("module::backlight::update_read")
end,
widget.widget
)
return widget