diff --git a/bin/omarchy-cmd-audio-switch b/bin/omarchy-cmd-audio-switch new file mode 100755 index 00000000..2377a123 --- /dev/null +++ b/bin/omarchy-cmd-audio-switch @@ -0,0 +1,19 @@ +#!/bin/bash + +# Find all the audio sinks but exit if there are none +sinks=($(wpctl status | sed -n '/Sinks:/,/Sources:/p' | grep -E '^\s*│\s+\*?\s*[0-9]+\.' | sed -E 's/^[^0-9]*([0-9]+)\..*/\1/')) +[ ${#sinks[@]} -eq 0 ] && exit 1 + +# Find current audio sink +current=$(wpctl status | sed -n '/Sinks:/,/Sources:/p' | grep '^\s*│\s*\*' | sed -E 's/^[^0-9]*([0-9]+)\..*/\1/') + +# Find the next sink (looping around in the list) +for i in "${!sinks[@]}"; do + [ "${sinks[$i]}" = "$current" ] && next=${sinks[$(((i + 1) % ${#sinks[@]}))]} +done +next=${next:-${sinks[0]}} + +# Set the next sink and ensure it's not muted +wpctl set-default "$next" +wpctl set-mute "$next" 0 + diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index 5145ba62..efedbb72 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -20,3 +20,6 @@ bindld = , XF86AudioNext, Next track, exec, $osdclient --playerctl next bindld = , XF86AudioPause, Pause, exec, $osdclient --playerctl play-pause bindld = , XF86AudioPlay, Play, exec, $osdclient --playerctl play-pause bindld = , XF86AudioPrev, Previous track, exec, $osdclient --playerctl previous + +# Switch audio output with Super + Mute +bindld = SUPER, XF86AudioMute, Switch audio output, exec, omarchy-cmd-audio-switch