local volume = req_rel(..., "util") return function(s) local widget = wibox.widget { { { { { -- Icon and margins nil, { nil, { id = "icon", forced_height = beautiful.dpi(100), image = beautiful.icons.volume.high, widget = wibox.widget.imagebox }, nil, expand = "none", id = "icon_margin2", layout = wibox.layout.align.vertical }, nil, id = "icon_margin1", expand = "none", layout = wibox.layout.align.horizontal }, { -- Text and percentage { id = "label", text = "Volume", align = "left", valign = "center", widget = wibox.widget.textbox }, nil, { id = "value", text = "0%", align = "center", valign = "center", widget = wibox.widget.textbox }, id = "label_value_layout", forced_height = beautiful.dpi(48), layout = wibox.layout.align.horizontal, }, { -- Progress bar { id = "volume_bar", shape = gears.shape.rounded_bar, forced_height = beautiful.dpi(10), background_color = "#AAAAAA88", bar_color = "#ffffff", color = "#ffffff", bar_shape = gears.shape.rounded_bar, max_value = 100, widget = wibox.widget.progressbar }, id = "bar_layout", forced_height = beautiful.dpi(24), widget = wibox.container.place }, id = "icon_bar_layout", spacing = beautiful.dpi(0), layout = wibox.layout.align.vertical }, id = "popup_layout", layout = wibox.layout.align.vertical, }, id = "container", left = beautiful.dpi(20), right = beautiful.dpi(20), top = beautiful.dpi(10), bottom = beautiful.dpi(10), widget = wibox.container.margin }, bg ="#000000FF", widget = wibox.container.background, ontop = true, visible = true, type = "notification", forced_height = beautiful.dpi(180), forced_width = beautiful.dpi(300), offset = beautiful.dpi(5), } local popup_container = awful.popup { widget = wibox.container.background, ontop = true, bg = "#00000000", stretch = false, visible = false, screen = s, placement = function(c) awful.placement.bottom_right( c, { honor_workarea = true, margins = { top = beautiful.dpi(200) } } ) end, -- Only set corner radius here. shape = function(cr, width, height) gears.shape.partially_rounded_rect( cr, width, height, true, false, false, false, beautiful.dpi(20) ) end } popup_container:setup { widget, layout = wibox.layout.fixed.horizontal } local hide_popup_timer = gears.timer { timeout = 1, autostart = true, callback = function() popup_container.visible = false end } awesome.connect_signal("module::all:popup_hide", function(except) if (except == "volume") then return end popup_container.visible = false if hide_popup_timer.started then hide_popup_timer:stop() end end ) awesome.connect_signal("module::volume:update", function(status) -- Update slider widget. container. popup_layout. icon_bar_layout. bar_layout. volume_bar:set_value(status.value) -- Update text widget. container. popup_layout. icon_bar_layout. label_value_layout. value:set_text(status.value .. "%") -- Update icon local icon if status.mute then icon = beautiful.icons.volume.mute elseif status.value < 1 then icon = beautiful.icons.volume.off elseif status.value >= 1 and status.value < 34 then icon = beautiful.icons.volume.low elseif status.value >= 34 and status.value < 67 then icon = beautiful.icons.volume.medium elseif status.value >= 67 then icon = beautiful.icons.volume.high end widget. container. popup_layout. icon_bar_layout. icon_margin1. icon_margin2. icon:set_image(icon) end ) awesome.connect_signal("module::volume:popup_show", function() awesome.emit_signal("module::all:popup_hide", "volume") if s == mouse.screen then popup_container.visible = true end if hide_popup_timer.started then hide_popup_timer:again() else hide_popup_timer:start() end end ) awesome.connect_signal("module::volume:popup_show_stay", function() awesome.emit_signal("module::all:popup_hide", "volume") if s == mouse.screen then popup_container.visible = true end if hide_popup_timer.started then hide_popup_timer:stop() end end ) popup_container:connect_signal("button::press", function(_, _, _, button, mods) -- Left-click if (button == 1) then volume.toggle_mute() -- Scroll up elseif (button == 4) then volume.volume_up(config.volume.scroll_step) -- Scroll down elseif (button == 5) then volume.volume_down(config.volume.scroll_step) end end ) popup_container:connect_signal("mouse::enter", function(result) awesome.emit_signal("module::volume:popup_show_stay") end) popup_container:connect_signal("mouse::leave", function(result) awesome.emit_signal("module::volume:popup_show") end) end