Skip to content

Instantly share code, notes, and snippets.

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