Created
May 29, 2013 18:23
-
-
Save indec/5672523 to your computer and use it in GitHub Desktop.
Shell script to drive https://github.com/deweller/switchaudio-osx from Alfred
This file contains 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="Generic USB Audio Device " | |
speakers="Display Audio" | |
arg=$1 | |
if [ "${arg}" = "headphones" ]; then | |
target=${headphones} | |
elif [ "${arg}" = "speakers" ]; then | |
target=${speakers} | |
else | |
foo=$( /usr/local/bin/SwitchAudioSource -c ) | |
if [ "${foo}" = "${headphones}" ]; then | |
target=${speakers} | |
arg="speakers" | |
else | |
target=${headphones} | |
arg="headphones" | |
fi | |
fi | |
for type in "output" "input" "system"; do | |
/usr/local/bin/SwitchAudioSource -t "$type" -s "$target" 2>&1 > /dev/null | |
done | |
/usr/local/bin/growlnotify --image /System/Library/PreferencePanes/Sound.prefPane/Contents//Resources/SoundPref.icns -name "Audio switcher" -m "Switched audio to $arg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment