2024-02-18 20:26:15 -08:00
|
|
|
local gears = require("gears")
|
|
|
|
local awful = require("awful")
|
|
|
|
local wibox = require("wibox")
|
2024-02-24 14:01:36 -08:00
|
|
|
local beautiful = require("beautiful")
|
2024-02-18 20:26:15 -08:00
|
|
|
local helpers = require("helpers")
|
|
|
|
|
2024-02-24 14:01:36 -08:00
|
|
|
local theme = beautiful.get()
|
|
|
|
local dpi = beautiful.xresources.apply_dpi
|
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
local slider = wibox.widget({
|
|
|
|
bar_shape = helpers.ui.rrect(9),
|
|
|
|
bar_height = 6,
|
2024-02-24 14:01:36 -08:00
|
|
|
bar_color = theme.bg_focus,
|
2024-02-25 17:42:33 -08:00
|
|
|
bar_active_color = theme.color.yellow,
|
2024-02-19 19:41:33 -08:00
|
|
|
handle_shape = gears.shape.circle,
|
2024-02-25 17:42:33 -08:00
|
|
|
handle_color = theme.color.yellow,
|
2024-02-24 14:01:36 -08:00
|
|
|
handle_width = dpi(12),
|
|
|
|
value = dpi(25),
|
2024-02-19 19:41:33 -08:00
|
|
|
widget = wibox.widget.slider,
|
|
|
|
})
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
helpers.ui.add_hover_cursor(slider, "hand1")
|
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
local bri_slider = wibox.widget({
|
|
|
|
{
|
2024-02-25 17:42:33 -08:00
|
|
|
markup = helpers.ui.colorize_text(" ", theme.color.yellow),
|
2024-02-24 14:01:36 -08:00
|
|
|
font = helpers.ui.set_font("14"),
|
2024-03-06 18:07:56 -08:00
|
|
|
halign = "center",
|
2024-02-19 19:41:33 -08:00
|
|
|
valign = "center",
|
|
|
|
widget = wibox.widget.textbox(),
|
|
|
|
},
|
|
|
|
slider,
|
|
|
|
layout = wibox.layout.fixed.horizontal,
|
|
|
|
spacing = 0,
|
|
|
|
})
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
awful.spawn.easy_async_with_shell(
|
|
|
|
"brightnessctl | grep -i 'current' | awk '{ print $4}' | tr -d \"(%)\"",
|
|
|
|
function(stdout)
|
|
|
|
local value = string.gsub(stdout, "^%s*(.-)%s*$", "%1")
|
|
|
|
bri_slider.value = tonumber(value)
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
slider:connect_signal("property::value", function(_, new_value)
|
|
|
|
slider.value = new_value
|
|
|
|
awful.spawn("brightnessctl set " .. new_value .. "%", false)
|
|
|
|
end)
|
|
|
|
|
|
|
|
return bri_slider
|