Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- switch() { /usr/local/bin/SwitchAudioSource "$@"; }
- OLDIFS="$IFS"
- IFS=$'\n'
- ####
- ao_hw_in=( $(switch -a | awk -F'[()]' '/input/{print substr($1,1,length($1)-1)}') )
- ao_hw_out=( $(switch -a | awk -F'[()]' '/output/{print substr($1,1,length($1)-1)}') )
- ao_active_out="$(switch -c)"
- ####
- IFS="$OLDIFS"
- if [ "$ao_active_out" == "${ao_hw_out[0]}" ]; then
- switch -t input -s "${ao_hw_in[1]}" &>/dev/null
- switch -t output -s "${ao_hw_out[1]}" &>/dev/null
- elif [ "$ao_active_out" == "${ao_hw_out[1]}" ]; then
- switch -t input -s "${ao_hw_in[0]}" &>/dev/null;
- switch -t output -s "${ao_hw_out[0]}" &>/dev/null
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement