Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. switch() { /usr/local/bin/SwitchAudioSource "$@"; }
  4.  
  5. OLDIFS="$IFS"
  6. IFS=$'\n'
  7. ####
  8. ao_hw_in=( $(switch -a | awk -F'[()]' '/input/{print substr($1,1,length($1)-1)}') )
  9. ao_hw_out=( $(switch -a | awk -F'[()]' '/output/{print substr($1,1,length($1)-1)}') )
  10. ao_active_out="$(switch -c)"
  11. ####
  12. IFS="$OLDIFS"
  13.  
  14. if [ "$ao_active_out" == "${ao_hw_out[0]}" ]; then
  15. switch -t input -s "${ao_hw_in[1]}" &>/dev/null
  16. switch -t output -s "${ao_hw_out[1]}" &>/dev/null
  17. elif [ "$ao_active_out" == "${ao_hw_out[1]}" ]; then
  18. switch -t input -s "${ao_hw_in[0]}" &>/dev/null;
  19. switch -t output -s "${ao_hw_out[0]}" &>/dev/null
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement