Skip to content

Instantly share code, notes, and snippets.

@iley
Created March 25, 2012 08:18
Show Gist options
  • Save iley/2192354 to your computer and use it in GitHub Desktop.
Save iley/2192354 to your computer and use it in GitHub Desktop.
Change output device in pulseaudio
#!/usr/bin/env bash
sinks=($(pacmd list-sinks | grep index | \
awk '{ if ($1 == "*") print "1",$3; else print "0",$2 }'))
inputs=($(pacmd list-sink-inputs | grep index | awk '{print $2}'))
[[ ${sinks[0]} = 0 ]] && swap=${sinks[1]} || swap=${sinks[3]}
pacmd set-default-sink $swap &> /dev/null
for i in ${inputs[*]}; do pacmd move-sink-input $i $swap &> /dev/null; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment