Created
January 2, 2019 00:09
-
-
Save codeanpeace/15dbefaf027136392dd50146959bb9a2 to your computer and use it in GitHub Desktop.
AppleScript that switches audio, toggling between display and AMP / DAC
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
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.sound" | |
end tell | |
tell application "System Events" | |
tell application process "System Preferences" | |
tell tab group 1 of window "Sound" | |
delay 1 | |
click radio button "Output" | |
if (selected of row 4 of table 1 of scroll area 1) then | |
set selected of row 3 of table 1 of scroll area 1 to true | |
set deviceselected to "Display Audio" | |
else | |
set selected of row 4 of table 1 of scroll area 1 to true | |
set deviceselected to "FiiO USB DAC-E10" | |
end if | |
end tell | |
end tell | |
end tell | |
tell application "System Preferences" | |
quit | |
end tell | |
tell application "Growl" | |
set the allNotificationsList to {"Sound Notification"} | |
set the enabledNotificationsList to {"Sound Notification"} | |
register as application "Toggle Sound Output" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor" | |
notify with name "Sound Notification" title "Audio Output" description deviceselected application name "Toggle Sound Output" | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See alternative command-line utility switchaudio-osx:
$ brew install switchaudio-osx
$ switchaudiosource -s "FiiO USB DAC-E10"
$ switchaudiosource -s "Display Audio"