mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-14 20:24:22 +02:00
Sometimes, muting/unmuting a specific device does not work, while it work with pavucontrol. But with pavucontrol, the device is not suspended. It seems that unsuspending the device from command line does not keep the device unsuspended for too long (or not at all?), so it may not work.
29 lines
1.1 KiB
Bash
Executable file
29 lines
1.1 KiB
Bash
Executable file
#!/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 }
|
|
/^\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]
|
|
print "pactl suspend-'$1' "source " false";
|
|
print "pactl set-'$1'-mute "source" "(!allmuted);
|
|
}
|
|
}' \
|
|
| sh
|
|
;;
|
|
esac
|