Last active
May 19, 2020 22:56
-
-
Save Sporif/f9033661b955d94765a1c4996023010c to your computer and use it in GitHub Desktop.
Set default pulseaudio sink
This file contains 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
#!/usr/bin/env bash | |
# Set default pulseaudio sink and move all sink inputs there | |
# Requires | |
# load-module module-stream-restore restore_device=false | |
# in /etc/pulse/default.pa | |
[ -z "$1" ] && echo "You must specify a sink (either index or name): | |
$(pacmd list-sinks | grep index -A 1)" && exit 1 | |
# New default sink | |
SINK="${1}" | |
# Driver to identify sink inputs to move | |
SINK_INPUT_DRIVER="protocol-native.c" | |
# Sink inputs to move | |
SINK_INPUTS="$(pacmd list-sink-inputs | grep "${SINK_INPUT_DRIVER}" -B 1 | awk '$1 == "index:" {print $2}')" | |
pacmd set-default-sink "${SINK}" && [ -n "${SINK_INPUTS}" ] && for i in ${SINK_INPUTS}; do | |
pacmd move-sink-input "${i}" "${SINK}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment