#!/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" notify_opts=() if [[ "$target_value" = "yes" ]]; then notify_opts=(-h "string:bgcolor:#ff0000" -h "string:fgcolor:#000000") else notify_opts=(-h "string:bgcolor:#00ff00" -h "string:fgcolor:#000000") fi notify-send "${notify_opts[@]}" -h string:x-canonical-private-synchronous:"${0##*/}" -t 3000 "Microphone mute: $target_value"