How to mute/unmute default sound output

What’s the generic way to mute/unmute my system’s default sound output?

$ amixer set Master mute
amixer: Unable to find simple control 'Master',0

$ amixer scontrols
Simple mixer control 'IEC958',0
Simple mixer control 'IEC958',1
Simple mixer control 'IEC958',2
Simple mixer control 'IEC958',3
Simple mixer control 'IEC958',4
Simple mixer control 'IEC958',5

I know the sound control had been moving away from amixer to Pulseaudio, however, I’m still able to use the ALSA "Master" control in my Debian 10, but not my Ubuntu 21.10, see above.

There is pactl set-sink-mute 0 1 from https://superuser.com/questions/805525/, but I tried it but that doesn’t work for my Ubuntu 21.10 above.

All in all, I just need a generic way to mute/unmute my system’s default sound output that is good across all my machines and all my Linuxes, just like the ALSA "Master" control.

Asked By: xpt

||

to mute:

pactl set-sink-mute `pactl get-default-sink` 1

to unmute :

pactl set-sink-mute `pactl get-default-sink` 0
Answered By: xpt

I’ve been using this command for ages now:

pactl set-sink-mute @DEFAULT_SINK@ toggle

This mutes/unmutes depending on the current state.


Also to increase volume: pactl set-sink-volume @DEFAULT_SINK@ +3%
or decrease volume: pactl set-sink-volume @DEFAULT_SINK@ -3%

Answered By: Artem S. Tashkinov

With the toggle option, it mutes everything. However, toggle Master does not unmute everything.

So, if we toggle Master, and always unmute the sub-channels, then Master will toggle, and the (sub-) channels will always unmute.

So I made a 3 line script ::

will@will:~$ cat toggle 
amixer -c 1 set Master toggle
amixer -c 1 set Headphone unmute
amixer -c 1 set Speaker unmute

enter image description here

Then bind the script to the key … because I’m to lazy to press the Fn – mute / vol+ / vol- combination for my keyboard.
enter image description here

Answered By: Will Cline