awesomewm/modules/backlight/widget.lua

62 lines
1.4 KiB
Lua
Raw Normal View History

2022-07-16 16:06:02 -07:00
local backlight = req_rel(..., "util")
local widget = {}
2023-08-26 17:38:33 -07:00
local dotgrid = require("widgets.dotgrid")
2022-07-16 16:06:02 -07:00
2023-08-26 17:38:33 -07:00
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)
2022-07-16 16:06:02 -07:00
widget.widget = wibox.widget {
{
2023-08-26 17:38:33 -07:00
widget.dots,
top = beautiful.dpi(2),
bottom = beautiful.dpi(2),
left = beautiful.dpi(2),
right = beautiful.dpi(2),
layout = wibox.container.margin,
2022-07-16 16:06:02 -07:00
},
layout = wibox.container.background,
}
widget.widget:connect_signal("mouse::enter", function(result)
widget.widget.bg = beautiful.color.bar.hover_bg
2022-11-19 10:20:15 -08:00
awesome.emit_signal("module::backlight:popup_show_stay")
2022-07-16 16:06:02 -07:00
end)
widget.widget:connect_signal("mouse::leave", function(result)
widget.widget.bg = beautiful.color.transparent
2022-11-19 10:20:15 -08:00
awesome.emit_signal("module::backlight:popup_show")
2022-07-16 16:06:02 -07:00
end)
widget.widget:connect_signal("button::press",
function(_, _, _, button, mods)
-- Scroll up
if (button == 4) then
2022-11-05 11:31:12 -07:00
backlight.backlight_up(config.backlight.scroll_step)
2022-07-16 16:06:02 -07:00
-- Scroll down
elseif (button == 5) then
2022-11-05 11:31:12 -07:00
backlight.backlight_down(config.backlight.scroll_step)
2022-07-16 16:06:02 -07:00
end
2022-11-05 11:40:42 -07:00
awesome.emit_signal("module::backlight:popup_show_stay")
2022-07-16 16:06:02 -07:00
end
)
2022-11-05 11:31:12 -07:00
awesome.connect_signal("module::backlight:update",
function(value)
2023-08-26 17:38:33 -07:00
widget.dots.value = value
widget.dots:emit_signal("widget::redraw_needed")
2022-11-05 11:31:12 -07:00
end
)
2022-07-16 16:06:02 -07:00
backlight.watch(
5,
function()
2022-11-05 11:31:12 -07:00
awesome.emit_signal("module::backlight::update_read")
2022-07-16 16:06:02 -07:00
end,
widget.widget
)
return widget