#!/bin/bash # Output from pactl is long. We're looking for the section under "Sink 1", about # 10 lines is enough. In those lines we're looking fore "Mute: yes" or "Mute: # no". We're counting how many times we find "Mute: yes" to see if volume is # already muted. # Note that sink 1 is hard coded, but you could rewrite this to accept any sink # or even affect all sinks. ISMUTED=`pactl list | grep "Sink #1" -A 10 | grep "Mute:" | grep "yes" -c` if (( $ISMUTED )) then pactl set-sink-mute 1 0 else pactl set-sink-mute 1 1 fi