#!/bin/bash target_value=$(if [[ $(pactl get-source-mute '@DEFAULT_SOURCE@' | sed 's/Mute: //') == "yes" ]]; then echo "no"; else echo "yes"; fi) pacmd list-sources | grep -oP 'index: \d+' | awk '{ print $2 }' | xargs -I{} pactl set-source-mute {} "$target_value"