Skip to content

Instantly share code, notes, and snippets.

@alete89
Created February 20, 2019 22:52
Show Gist options
  • Save alete89/2d2f72c93f1257b4959b83718727e9ae to your computer and use it in GitHub Desktop.
Save alete89/2d2f72c93f1257b4959b83718727e9ae to your computer and use it in GitHub Desktop.
Switch sound output device
#!/bin/bash
new_sink=$(pacmd list-sinks | grep index | tee /dev/stdout | grep -m1 -A1 "* index" | tail -1 | cut -c12-)
echo "Setting default sink to: $new_sink";
pacmd set-default-sink $new_sink
pacmd list-sink-inputs | grep index | while read line
do
echo "Moving input: ";
echo $line | cut -f2 -d' ';
echo "to sink: $new_sink";
pacmd move-sink-input `echo $line | cut -f2 -d' '` $new_sink
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment