You need a script to do this. There are scripts like this that control the default sink, but I haven't seen one that controls all sinks.
You can get a list of all sinks with pacmd list-sinks
, and set the volume with pacmd set-sink-volume
, so you need to do something like
VOLUME='+5%'
for SINK in $(pacmd list-sinks | grep 'index:' | cut -b12-)
do
pactl set-sink-volume $SINK $VOLUME
done
Where $VOLUME
can be absolute (150%
) or relative (+5%
, -5%
), and possibly other formats, too.
Most window managers can be configured to launch scripts or programs, complete with arguments, when you press keys. That's the best method, but if your WM doesn't, there are tools like xbindkeys
. So you can customize in any way you want.
Note that Pulseaudio will start using hardware mixers if the sink volume goes over 100%, and that can distort the sound.
Also note that Pulseaudio allows to set the volume for each application ("audio stream") with pacmd set-sink-input-volume
. You can list them with pacmd list-sink-inputs
and set them similarly.
That allows you to have the sink volumes at a fixed level, so they are about equal, without using hardware mixers, and when you switch sinks, it will automatically have the "right" volume. That's the setup I prefer.
$VOLUME
returns "Failed to parse volume" errors. Changing the inner line topactl set-sink-volume $SINK $VOLUME
works. Thanks! =) – Ted Jun 29 '17 at 09:18pactl
andpacmd
. – dirkt Jun 29 '17 at 09:29pacmd list-sinks | grep -B 4 RUNNING | grep index | awk ' { print $NF } '
also seems to work.The nice part of this approach is you're probably only using one audio output at once so you can dump the loop if you add a
– kristopolous Sep 22 '20 at 22:39head -1
in there.