1
0
Fork 0
archlinux/home/oli/bin/i3blocks/mic_mute

33 lines
690 B
Text
Raw Normal View History

#!/usr/bin/env bash
#
# Shows microphone mute status for the default audio source.
# Left click toggles mute.
. ~/bin/i3blocks/_utils
mic_mute() {
if [[ "$BLOCK_BUTTON" == "1" ]]; then
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
fi
local wpctl_output
wpctl_output=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)
local muted
muted=$(echo "$wpctl_output" | grep -c '\[MUTED\]')
local bg fg icon stat
if [[ "$muted" -ge 1 ]]; then
bg=$mute_bg
fg=$mute_fg
stat="MUT"
else
bg=$crit_bg
fg=$crit_fg
stat="REC"
fi
echo -e "MIC <span background=\"$bg\" color=\"$fg\"> $stat </span>\n"
}
mic_mute