I’m frequently changing the audio setup of my laptop (sometimes using the built-in jack port, sometimes nothing at all, sometimes using USB headphones, sometimes using the jack port in the dock of my laptop). I’d like to have keyboard shortcuts to lower or increase volume for all outputs at once, so it works no matter which audio output is currently active. What’s the easiest way to achieve this? I also see that in pavucontrol, I can go above 100%, which is sometimes practical, so if the command was also able to do this, that’d be great.
I’m running Debian Testing, kernel 4.9.0-3-amd64, and pulseaudio 10.0.
Here is Solutions:
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
$VOLUME can be absolute (
150%) or relative (
-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.
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂