vincentbernat.i3wm-configur.../bin/toggle-mute

29 lines
1 KiB
Text
Raw Normal View History

2022-09-20 08:08:10 +02:00
#!/bin/sh
# Toggle mute on all sinks or sources.
case $1 in
source|sink)
pactl list ${1}s \
| awk '/^(Source|Sink) / { source=substr($2,2) }
/^\tName: .*.monitor$/ { source=0 }
/^\tDescription: / { sub("^[^:]*: ", ""); descriptions[source] = $0 }
2022-09-20 08:08:10 +02:00
/^\tMute: / { if (source > 0) muted[source] = ($2 == "yes") }
END {
if (length(muted) == 0) exit;
allmuted=1;
for (source in muted) {
if (!muted[source]) {
allmuted=0;
}
}
for (source in muted) {
gsub(/['"'"'"\\\$\(\)`]/, "\\\\&", descriptions[source])
print "echo "(allmuted?"🔊":"🔇")" "descriptions[source]
2022-09-20 08:08:10 +02:00
print "pactl set-'$1'-mute "source" "(!allmuted);
}
}' \
| sh
;;
esac