Last active
September 30, 2022 10:30
-
-
Save j2L4e/ae1042fc5968225fc3b6095d670fe273 to your computer and use it in GitHub Desktop.
Set pulseaudio default sink to the next available sink and move all existing sink-inputs to the new default. Wraps around once the last input is reached.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Set pulseaudio default sink to the next available sink and move all existing sink-inputs to the new default. | |
| # Wraps around once the last available sink is reached. | |
| # | |
| # (C) 2022, @j2L4e | |
| # MIT License | |
| currentline=$(pactl list short sinks | grep -n "$(pactl get-default-sink)" | cut -d: -f 1) | |
| lastline=$(pactl list short sinks | wc -l) | |
| nextline=$(($currentline % $lastline + 1)) | |
| nextsink=$(pactl list short sinks | head "-n$nextline" | tail -1 | cut -f 1) | |
| pactl set-default-sink "$nextsink" | |
| for sinkinput in $(pactl list short sink-inputs | cut -f 1); do | |
| pactl move-sink-input "$sinkinput" "@DEFAULT_SINK@" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment