diff --git a/bin/toggle-mute b/bin/toggle-mute new file mode 100755 index 0000000..a1e42a0 --- /dev/null +++ b/bin/toggle-mute @@ -0,0 +1,25 @@ +#!/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 } + /^\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) { + print "pactl set-'$1'-mute "source" "(!allmuted); + } + }' \ + | sh + ;; +esac diff --git a/config b/config index 8149bb6..60ce80d 100644 --- a/config +++ b/config @@ -29,8 +29,8 @@ gaps inner 10 # audio bindsym XF86AudioRaiseVolume exec --no-startup-id exec pactl set-sink-volume @DEFAULT_SINK@ +5% bindsym XF86AudioLowerVolume exec --no-startup-id exec pactl set-sink-volume @DEFAULT_SINK@ -5% -bindsym XF86AudioMute exec --no-startup-id exec pactl set-sink-mute @DEFAULT_SINK@ toggle -bindsym XF86AudioMicMute exec --no-startup-id exec pactl set-source-mute @DEFAULT_SOURCE@ toggle +bindsym XF86AudioMute exec --no-startup-id exec ~/.config/i3/bin/toggle-mute sink +bindsym XF86AudioMicMute exec --no-startup-id exec ~/.config/i3/bin/toggle-mute source bindsym XF86AudioPlay exec --no-startup-id exec playerctl -p $mediaplayer play-pause bindsym XF86AudioPause exec --no-startup-id exec playerctl -p $mediaplayer pause bindsym XF86AudioStop exec --no-startup-id exec playerctl -p $mediaplayer stop