Added backlight module

This commit is contained in:
2022-07-16 16:06:02 -07:00
parent 8e8c4840da
commit 3014105bbf
12 changed files with 178 additions and 180 deletions

View File

@ -10,7 +10,6 @@ local desktop = {
tagindicator = require("desktop.widgets.tagindicator"),
launcher = require("desktop.widgets.launcher"),
shortcut = require("desktop.widgets.shortcut"),
--winstat = require("desktop.widgets.window_status"),
space = function(size)
return wibox.widget {
@ -45,7 +44,7 @@ local desktop = {
-- Load conditional modules
if conf.backlight_enabled then
desktop.widgets.backlight = require("desktop.widgets.backlight")
desktop.widgets.backlight = modules.backlight.widgets.backlight
end
if conf.battery_enabled then
desktop.widgets.battery = require("desktop.widgets.battery")

View File

@ -1,101 +0,0 @@
local backlight = {}
backlight.icon = wibox.widget {
id = "icon",
image = beautiful.icons.brightness.i,
resize = true,
widget = wibox.widget.imagebox,
}
backlight.arc = wibox.widget {
{
backlight.icon,
top = beautiful.dpi(1),
bottom = beautiful.dpi(1),
layout = wibox.container.margin,
},
max_value = 100,
thickness = beautiful.dpi(4),
start_angle = 4.71238898, -- 2pi*3/4
--forced_height = beautiful.dpi(16),
--forced_width = beautiful.dpi(16),
colors = {"#27D4CC", "#00446B"},
bg = "#FFFFFF30",
paddings = beautiful.dpi(2),
widget = wibox.container.arcchart
}
backlight.widget = wibox.widget {
{
{ -- Right space
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
{ -- Main indicator. Can be replaced with backlight.arc
backlight.arc,
top = beautiful.dpi(2),
bottom = beautiful.dpi(2),
layout = wibox.container.margin,
},
{ -- Left space
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
layout = wibox.layout.align.horizontal,
},
layout = wibox.container.background,
}
backlight.widget:connect_signal("mouse::enter", function(result)
backlight.widget.bg = beautiful.color.bar.hover_bg
end)
backlight.widget:connect_signal("mouse::leave", function(result)
backlight.widget.bg = beautiful.color.transparent
end)
backlight.widget:connect_signal("button::press",
function(_, _, _, button, mods)
-- Scroll up
if (button == 4) then
wrapper.backlight.up()
-- Scroll down
elseif (button == 5) then
wrapper.backlight.down()
end
end
)
backlight.update = function(value)
backlight.arc.value = value
--[[if value > 90 then backlight.icon.image = beautiful.icons.brightness.i
elseif value > 80 then backlight.icon.image = beautiful.icons.brightness.h
elseif value > 70 then backlight.icon.image = beautiful.icons.brightness.g
elseif value > 60 then backlight.icon.image = beautiful.icons.brightness.f
elseif value > 50 then backlight.icon.image = beautiful.icons.brightness.e
elseif value > 40 then backlight.icon.image = beautiful.icons.brightness.d
elseif value > 30 then backlight.icon.image = beautiful.icons.brightness.c
elseif value > 20 then backlight.icon.image = beautiful.icons.brightness.b
elseif value <= 10 then backlight.icon.image = beautiful.icons.brightness.a end
--]]
end
-- Add various hooks
wrapper.backlight.add_hook(backlight.update)
bin.backlight.watch(
5,
function()
wrapper.backlight.read(backlight.update)
end,
backlight.widget
)
return backlight.widget