lazy push before updates

This commit is contained in:
Noella
2025-12-30 13:23:54 -07:00
parent 44ab8019bc
commit 34b678e020
30 changed files with 727 additions and 208 deletions

68
widgets/volume.lua Normal file
View File

@@ -0,0 +1,68 @@
local awful = require("awful")
local beautiful = require("beautiful")
local wibox = require("wibox")
local _M = {}
function _M.update(stdout)
local vol_now = {
volume = "N/A",
muted = "N/A",
icon = "N/A",
}
vol_now.volume = stdout:gsub("%s+", "")
vol_now.volume = vol_now.volume:gsub("%%", "")
if vol_now.volume == "muted" then
vol_now.muted = true
vol_now.volume = -1
else
vol_now.volume = tonumber(vol_now.volume)
vol_now.muted = false
end
if vol_now.muted or vol_now.volume == 0 then
vol_now.icon = beautiful.volume_muted_icon
elseif vol_now.volume >= 66 then
vol_now.icon = beautiful.volume_high_icon
elseif vol_now.volume >= 33 then
vol_now.icon = beautiful.volume_medium_icon
else
vol_now.icon = beautiful.volume_low_icon
end
return vol_now
end
function _M.get()
local volume = awful.widget.watch(
{
awful.util.shell,
"-c",
"pamixer --get-volume-human",
},
1,
function(widget, stdout)
local vol_now = _M.update(stdout)
local icon = wibox.widget.imagebox(vol_now.icon)
local text = wibox.widget.textbox(vol_now.volume .. "% ")
widget.children = {
text,
icon,
}
end,
wibox.widget({
layout = wibox.layout.fixed.horizontal,
})
)
return volume
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})