Created
January 11, 2014 22:04
-
-
Save einarlove/8377578 to your computer and use it in GitHub Desktop.
This NSApplescript toggles between the Internal Speakers and Apple TV. Could be saved as a service and triggered by keyboard shortcut or as an Alfred workflow
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
(* | |
-- Change audio output between two outputs | |
-- Bind to a keyboard shortcut or an Alfred keyword | |
-- | |
-- @author Einar Löve <[email protected]> | |
-- @link http://github.com/einarlove | |
*) | |
set defaultOutput to "Internal Speakers" | |
set alternativeOutput to "Apple TV" | |
tell application "System Preferences" | |
reveal anchor "output" of pane id "com.apple.preference.sound" | |
tell application "System Events" | |
tell process "System Preferences" | |
set outputList to table 1 of scroll area 1 of tab group 1 of window "Sound" | |
set currentOutput to value of text field of UI element 1 of outputList whose selected = true | |
set outputName to first item of currentOutput | |
if outputName is defaultOutput then | |
set outputName to alternativeOutput | |
else | |
set outputName to defaultOutput | |
end if | |
select (row 1 of outputList whose value of text field 1 is outputName) | |
end tell | |
end tell | |
quit | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a bunch for this!