Created
October 6, 2015 21:26
-
-
Save nmalacarne/cf392be62bc9157aa3dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| headPhones="alsa_output.usb-Turtle_Beach_Turtle_Beach_PX3__PC_-00-PX3PC.analog-stereo" | |
| speakers="alsa_output.pci-0000_00_14.2.analog-stereo" | |
| current=$(pactl list short sinks | grep "RUNNING" | cut -f2) | |
| if [ $current = $headPhones ]; then | |
| target=$speakers | |
| else | |
| target=$headPhones | |
| fi | |
| # set default output device | |
| pactl set-default-sink $target | |
| # move all output streams to new device | |
| pactl list short sink-inputs | while read stream; do | |
| id=$(echo $stream | cut '-d ' -f1) | |
| pactl move-sink-input "$id" "$target" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment