Skip to content

Instantly share code, notes, and snippets.

@DanielRussell
Last active September 25, 2015 14:56
Show Gist options
  • Save DanielRussell/3019283d7987daf19857 to your computer and use it in GitHub Desktop.
Save DanielRussell/3019283d7987daf19857 to your computer and use it in GitHub Desktop.
Set Sound Output
-- Set sound output, adapted from https://discussions.apple.com/message/20676485
--
-- Run as:
-- osascript Speakers.scpt -- Default to "Internal Speakers"
-- osascript Speakers.scpt "DELL P2715Q" -- Anything listed in System Preferences,
-- -- e.g. Monitor connected via HDMI
on run argv
set asrc to "Internal Speakers"
if (count of argv) > 0 then
set asrc to item 1 of argv
end if
tell application "System Preferences"
reveal anchor "output" of pane id "com.apple.preference.sound"
tell application "System Events"
tell process "System Preferences"
select (row 1 of table 1 of scroll area 1 of tab group 1 of window "Sound" whose value of text field 1 is asrc)
end tell
end tell
quit
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment