Skip to content

Instantly share code, notes, and snippets.

@rkfg
Last active August 29, 2015 14:27
Show Gist options
  • Save rkfg/bf85ab97b9a7783e57f9 to your computer and use it in GitHub Desktop.
Save rkfg/bf85ab97b9a7783e57f9 to your computer and use it in GitHub Desktop.
PulseAudio monitor switch
#!/bin/sh
INDEX=$(pacmd list-source-outputs | sed -n 's#\s*index\: \([0-9]*\)#\1#p' | head -n 1)
if [ -z "$INDEX" ]
then
exit 1
fi
MONITOR=$(pacmd list-sources | sed -n 's#\s*name: <\(.*\.monitor\)>#\1#p' | head -n 1)
INPUT=$(pacmd list-sources | sed -n 's#\s*name: <\(.*_input.*\)>#\1#p' | head -n 1)
if [ "$1" = "-m" ]
then
pacmd move-source-output $INDEX $MONITOR
else
pacmd move-source-output $INDEX $INPUT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment