>>108967677
On XFCE the volume widget allows you to change the output (and input) providing you have more than one. Around 4-5 years ago I needed something similar so I wrote a python script for this purpose and bound it to a keyboard shortcut. I think the original version had a bug with more than two sinks. I rewrote it as a shell script at some point but I don't remember why. I hate shell scripting beyond one liners and I'm borderline incompetent at it. I don't remember much of the details but it might be helpful:
# switches to the next audio sink
current=$(pactl get-default-sink)
target=-1
n=0
sink_count=$(pactl list short sinks | wc -l)
((sink_count-=1))
while read id name backend format channels frequency status; do
if [[ $current == $name ]]; then
if [[ $n == $sink_count ]]; then
target=0
else
target=$n
((target++))
fi
break 2
fi
((n++))
done <<< "$(pactl list short sinks)"
n=0
pactl list short sinks | while read id name backend format channels frequency status; do
if [[ $n == $target ]]; then
pactl set-default-sink "$name"
echo switched to "$name"
exit
fi
((n++))
done
I'm not aware of an easier way to do this. Other audio tasks are much simpler:
pactl set-sink-mute @DEFAULT_SINK@ toggle
pactl set-sink-volume @DEFAULT_SINK@ +5%
pactl set-sink-volume @DEFAULT_SINK@ -5%