2024-02-19 19:41:33 -08:00
|
|
|
local awful = require("awful")
|
|
|
|
local wibox = require("wibox")
|
|
|
|
local gears = require("gears")
|
2024-02-20 19:13:52 -08:00
|
|
|
local beautiful = require("beautiful").get()
|
|
|
|
local dpi = require("beautiful.xresources").apply_dpi
|
2024-02-19 19:41:33 -08:00
|
|
|
local helpers = require("helpers")
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
-- Icon
|
|
|
|
local icon = wibox.widget.textbox()
|
2024-02-19 19:41:33 -08:00
|
|
|
icon.font = beautiful.font_name .. "12.5"
|
|
|
|
icon.align = "center"
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
-- Uptime
|
|
|
|
local pulseaudio = wibox.widget.textbox()
|
2024-02-19 19:41:33 -08:00
|
|
|
pulseaudio.font = beautiful.font_name .. "10"
|
|
|
|
pulseaudio.align = "center"
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
local function get_val()
|
|
|
|
awesome.connect_signal("signal::volume", function(vol, muted)
|
2024-02-19 19:41:33 -08:00
|
|
|
if muted then
|
|
|
|
pulseaudio.markup = "muted"
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
|
|
|
else
|
|
|
|
pulseaudio.markup = tonumber(vol) .. "%"
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
2024-02-18 20:26:15 -08:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
get_val()
|
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
local full = wibox.widget({
|
2024-02-18 20:26:15 -08:00
|
|
|
{
|
|
|
|
{
|
2024-02-19 19:41:33 -08:00
|
|
|
icon,
|
|
|
|
pulseaudio,
|
|
|
|
spacing = dpi(8),
|
|
|
|
layout = wibox.layout.fixed.horizontal,
|
2024-02-18 20:26:15 -08:00
|
|
|
},
|
2024-02-19 19:41:33 -08:00
|
|
|
left = dpi(5),
|
|
|
|
right = 8,
|
|
|
|
layout = wibox.container.margin,
|
2024-02-18 20:26:15 -08:00
|
|
|
},
|
2024-02-19 19:41:33 -08:00
|
|
|
forced_width = 73,
|
2024-02-18 20:26:15 -08:00
|
|
|
layout = wibox.layout.fixed.horizontal,
|
2024-02-19 19:41:33 -08:00
|
|
|
})
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
full:buttons(gears.table.join(awful.button({}, 1, function()
|
|
|
|
awesome.emit_signal("action::toggle")
|
|
|
|
end)))
|
2024-02-18 20:26:15 -08:00
|
|
|
-- Update Function
|
2024-02-19 19:41:33 -08:00
|
|
|
local update_volume = function() -- Sets the Volume Correct
|
|
|
|
awful.spawn.easy_async_with_shell("pamixer --get-volume", function(stdout)
|
|
|
|
pulseaudio.markup = tonumber(stdout:match("%d+")) .. "%"
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
if tonumber(stdout:match("%d+")) < 10 then
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
|
|
|
elseif tonumber(stdout:match("%d+")) < 50 then
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
|
|
|
elseif tonumber(stdout:match("%d+")) < 100 then
|
|
|
|
icon.markup = "<span foreground='" .. beautiful.xcolor2 .. "'></span>"
|
|
|
|
else
|
|
|
|
end
|
2024-02-18 20:26:15 -08:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
update_volume()
|
|
|
|
awesome.connect_signal("widget::update_vol", function()
|
|
|
|
update_volume()
|
|
|
|
end)
|
|
|
|
awesome.connect_signal("widget::update_vol_pulse", function()
|
|
|
|
update_volume()
|
|
|
|
end)
|
|
|
|
helpers.ui.add_hover_cursor(full, "hand2")
|
|
|
|
|
|
|
|
return full
|