Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
5.81k stars 656 forks source link

Sink not matching default if app launched with different sink as default #3350

Open Kommynct opened 2 weeks ago

Kommynct commented 2 weeks ago

steps for reproducing:

  1. have two separate sinks (we will call them sink1 and sink2)
  2. change the default sink to sink1 with pavucontrol or whatever
  3. launch mpv with env PIPEWIRE_NODE=sink2 mpv --player-operation-mode=pseudo-gui ~/soundfile.ogg

notice waybar now has the volume of sink2 showing even though sink1 is the default. This doesn't change even if you open new apps or change the volume of the default sink, or even pkill waybar, unless you close the mpv window.

I use this command to switch sinks, not sure if it matters: pactl set-default-sink $(pactl list short sinks | awk '{print $2}' | sd 'easyeffects_sink\n' '' | sd "$(pactl get-default-sink)\n" '' | tofi --prompt-text " " --height 40% --width 40% --auto-accept-single true ) && pw-play --volume=0.2 /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga

I've also tested what happens if I launch it on sink1 and sink2 at the same time, while they're both open waybar starts stuck on sink2 like normal, but if i launch sink1 afterwards, it still stays on sink2, but does switch back to sink1 on a pkill, if i then kill the one on sink1 while leaving sink2 open, it instantly switches back, as though sink2 is locked due to the environment variable.

The same thing happens if you use mpv's audio device option like "mpv --audio-device=pipewire/sink2"

Kommynct commented 2 weeks ago

it appears to be an issue with using pactl because

wpctl set-default $(pw-cli i $(pactl list short sinks | awk '{print $2}' | sd 'easyeffects_sink\n' '' | sd "$(pactl get-default-sink)\n" '' | tofi --prompt-text " " --height 40% --width 40% --auto-accept-single true ) | rg -oP 'id: \K\w+') && pw-play --volume=0.2 /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga &!

seems to have resolved the problem for me, leaving the issue open because it should work with pactl too.

edit: nevermind, this just gives the illusion of fixing it, it works until you pkill waybar or waybar updates in any way