Find out whether sound output is muted (ALSA with Pulseaudio)

After a long search, I actually managed to find an answer. This might be helpful for others looking for something like this out there!

What you need:

pacmd list-sinks

This command has a line like this:

muted: no

And this no indeed does change to yes, when I mute my device. Perfect. I managed to strip the output using this command, should anyone need it:

pacmd list-sinks | awk '/muted/ { print $2 }'

Sorry for posting too soon, it seemed like I won't be able to find a solution anywhere.


Alternatively, for those like me who don't have PulseAudio or want to only use amixer, one solution is:

amixer get Master | sed 5q | grep -q '\[on\]'

returning 0 if unmuted and 1 if muted.