Skip to content

Instantly share code, notes, and snippets.

@j2L4e
Last active September 30, 2022 10:30
Show Gist options
  • Select an option

  • Save j2L4e/ae1042fc5968225fc3b6095d670fe273 to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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