2022-07-16 15:44:14 -07:00
|
|
|
local volume = req_rel(..., "util")
|
2021-08-01 07:24:26 -07:00
|
|
|
local widget = {}
|
|
|
|
|
|
|
|
|
|
|
|
widget.icon = wibox.widget {
|
|
|
|
resize = true,
|
|
|
|
image = beautiful.icons.volume.mute,
|
|
|
|
widget = wibox.widget.imagebox
|
|
|
|
}
|
|
|
|
|
|
|
|
widget.arc = wibox.widget {
|
|
|
|
{
|
|
|
|
widget.icon,
|
|
|
|
top = beautiful.dpi(1),
|
|
|
|
bottom = beautiful.dpi(1),
|
|
|
|
layout = wibox.container.margin,
|
|
|
|
},
|
|
|
|
max_value = 1,
|
|
|
|
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),
|
2022-11-05 09:47:15 -07:00
|
|
|
rounded_edge = true,
|
2021-08-01 07:24:26 -07:00
|
|
|
widget = wibox.container.arcchart
|
|
|
|
}
|
|
|
|
|
|
|
|
widget.bar = wibox.widget {
|
|
|
|
max_value = 100,
|
|
|
|
value = 0,
|
|
|
|
--forced_height = 20,
|
|
|
|
forced_width = beautiful.dpi(50),
|
|
|
|
paddings = 0,
|
|
|
|
border_width = 0,
|
|
|
|
color = {
|
|
|
|
type = "linear",
|
|
|
|
from = {0, 0}, to = {beautiful.dpi(50), 0},
|
|
|
|
stops = { { 0, "#27D4CC" }, { 1, "#00446B" }}
|
|
|
|
},
|
|
|
|
background_color = "#FFFFFF30",
|
|
|
|
widget = wibox.widget.progressbar,
|
|
|
|
shape = gears.shape.rounded_bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
widget.widget = wibox.widget {
|
|
|
|
{
|
|
|
|
{ -- Right space
|
|
|
|
widget = wibox.widget.separator,
|
|
|
|
color = beautiful.color.transparent,
|
|
|
|
forced_width = beautiful.dpi(3)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
widget.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,
|
|
|
|
}
|
|
|
|
|
|
|
|
widget.widget:connect_signal("mouse::enter", function(result)
|
|
|
|
widget.widget.bg = beautiful.color.bar.hover_bg
|
|
|
|
end)
|
|
|
|
|
|
|
|
widget.widget:connect_signal("mouse::leave", function(result)
|
|
|
|
widget.widget.bg = beautiful.color.transparent
|
|
|
|
end)
|
|
|
|
|
|
|
|
widget.widget:connect_signal("button::press",
|
|
|
|
function(_, _, _, button, mods)
|
|
|
|
|
2022-11-05 11:31:12 -07:00
|
|
|
-- Left-click
|
|
|
|
if (button == 1) then
|
2022-07-16 15:44:14 -07:00
|
|
|
volume.toggle_mute()
|
2021-08-01 07:24:26 -07:00
|
|
|
|
|
|
|
-- Scroll up
|
|
|
|
elseif (button == 4) then
|
2022-11-05 09:54:25 -07:00
|
|
|
volume.volume_up(config.volume.scroll_step)
|
2021-08-01 07:24:26 -07:00
|
|
|
|
|
|
|
-- Scroll down
|
|
|
|
elseif (button == 5) then
|
2022-11-05 09:54:25 -07:00
|
|
|
volume.volume_down(config.volume.scroll_step)
|
2021-08-01 07:24:26 -07:00
|
|
|
end
|
2022-11-05 11:40:42 -07:00
|
|
|
awesome.emit_signal("module::volume:popup_show_stay")
|
2021-08-01 07:24:26 -07:00
|
|
|
end
|
|
|
|
)
|
|
|
|
|
2022-11-05 09:47:15 -07:00
|
|
|
awesome.connect_signal("module::volume:update",
|
|
|
|
function(status)
|
|
|
|
if (status.value == false) then
|
|
|
|
widget.icon.image = beautiful.icons.volume.error
|
|
|
|
widget.arc.value = 100;
|
|
|
|
widget.bar.value = 100;
|
|
|
|
return
|
|
|
|
end
|
2021-08-01 07:24:26 -07:00
|
|
|
|
2022-11-05 09:47:15 -07:00
|
|
|
widget.arc.value = status.value / 100;
|
|
|
|
widget.bar.value = status.value;
|
|
|
|
|
|
|
|
|
|
|
|
if (status.mute) then
|
|
|
|
-- Set muted icon
|
|
|
|
widget.icon.image = beautiful.icons.volume.mute
|
|
|
|
else
|
|
|
|
-- Set icon by value
|
|
|
|
if status.value > 70 then
|
|
|
|
widget.icon.image = beautiful.icons.volume.high
|
|
|
|
elseif status.value > 40 then
|
|
|
|
widget.icon.image = beautiful.icons.volume.medium
|
|
|
|
elseif status.value > 0 then
|
|
|
|
widget.icon.image = beautiful.icons.volume.low
|
|
|
|
elseif status.value == 0 then
|
|
|
|
widget.icon.image = beautiful.icons.volume.off
|
|
|
|
end
|
2021-08-01 07:24:26 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
2022-07-16 15:44:14 -07:00
|
|
|
return widget
|