Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active December 28, 2016 18:09
Show Gist options
  • Save frafra/8067798 to your computer and use it in GitHub Desktop.
Save frafra/8067798 to your computer and use it in GitHub Desktop.
Select default sink for PulseAudio
#!/bin/bash
# select-default-subj.sh
# Description: Select default sink for PulseAudio
# Author: FraFra (Francesco Frassinelli - frafra.eu)
# License: GPLv3
SINKS=($(LC_ALL=C pactl list sinks | grep -P '^\tName: ' | cut -d ' ' -f 2))
DEFAULT=$(LC_ALL=C pactl info | grep '^Default Sink: ' | cut -d ' ' -f 3)
echo "Sinks:"
i=0
for sink in ${SINKS[@]}; do
echo -n "$i) $sink"
if [ $sink == $DEFAULT ]; then
echo -n " (*)"
fi
echo
let i++
done
let i--
echo -n "Select sink ID [0-$i]: "
read id
pactl set-default-sink ${SINKS[$id]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment