awesome-wm-widgets
awesome-wm-widgets copied to clipboard
Pactl volume-widget only updates on one screen
The pactl-widget does not update the value when I change the volume. I am using pipewire on Arch Linux. All the operations (like click and scroll) on the icon work. The volume also gets changed correctly. Only the icon and value (or bar) do not update (except when restarting the entire WM).
This is what I have in my rc.lua, like mentioned in the README of the widget.
local volume_widget = require('awesome-wm-widgets.pactl-widget.volume')
...
volume_widget(),
...
awful.key({}, "XF86AudioRaiseVolume", function () volume_widget:inc(5) end),
awful.key({}, "XF86AudioLowerVolume", function () volume_widget:dec(5) end),
awful.key({}, "XF86AudioMute", function () volume_widget:toggle() end),
...
I just cloned the repo to my ~/.config/awesome
directory, so I am using the most recent version of the widgets.
I just noticed that it does update correctly on my secondary display (I am using a dual monitor setup). The displayed value in the statusbar on my primary display stays at the initial value.
I think this is due to the pactl-widget storing the volume widget it's using in a single variable across all instances. volume
at https://github.com/streetturtle/awesome-wm-widgets/blob/master/pactl-widget/volume.lua#L27 has its property widget
set to a value returned by the volume-widget and later referenced in volume:toggle()
. But this will have been overwritten by the later call of the module.
One way to handle this is to instantiate the widget only once, out of awful.screen.connect_for_each_screen
loop.
local myvolume = volume_widget()
My solution is to place the widget only in the primary screen (in fact, all the widgets are in the primary screen) :
local weather_widget = require("awesome-wm-widgets.weather-widget.weather")
…
awful.screen.connect_for_each_screen(function(s)
…
local weather_wdg = nil
if s == screen.primary then
audio_wdg = {
layout = awful.widget.only_on_screen,
screen = screen.primary, -- Only display on primary screen
volume_widget{ }
}
end
…
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
…
},
s.mytasklist, -- Middle widget
{ -- Right widgets
audio_wdg,
…
s.mylayoutbox,
},
}
end
For people follows this default rc.lua file,
Any widgets defined within callback of screen.connect_signal("request::desktop_decoration")
should be shared across screens, such as the textclock
widget, while the promptbox
is not.
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
-- @DOC_FOR_EACH_SCREEN@
screen.connect_signal("request::desktop_decoration", function(s)
-- Each screen has its own tag table.
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
-- Create a promptbox for each screen
s.mypromptbox = awful.widget.prompt()
end)