Add SUPER + MUTE for audio output switching (#941)

* Add SUPER + MUTE for audio output switching

* Fix migration bc stupidness

* Simplify implementation and ensure the new sink is not muted

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
Christopher 2025-08-22 20:43:46 +02:00 committed by GitHub
parent 7c4156fc9d
commit 8c1fd76a37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

19
bin/omarchy-cmd-audio-switch Executable file
View File

@ -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

View File

@ -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