Skip to content

Instantly share code, notes, and snippets.

@seltzered
Last active October 21, 2022 18:17
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seltzered/3b627104c8a7a39b863c to your computer and use it in GitHub Desktop.
Save seltzered/3b627104c8a7a39b863c to your computer and use it in GitHub Desktop.
Mac OSX Set Sound Output to Internal Speakers.applescript
-- Script to set sound output - "Internal Speakers" hardcoded as I just keep multiple scripts for each output source (e.g. Internal Speakers, Airplay, bluetooth ) and use it with a quicklaunch app such as quicksilver.
-- Based off of Pierre L's answer in https://discussions.apple.com/thread/4629093?tstart=0 , which includes a selection dialog
set asrc to "Internal Speakers"
tell application "System Preferences"
reveal anchor "output" of pane id "com.apple.preference.sound"
activate
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
@danzar
Copy link

danzar commented Aug 20, 2020

Thanks, worked for me. :)

@ozyxdev
Copy link

ozyxdev commented May 27, 2021

This was very helpful using with Alfred! Thanks!

@ballacoilupi
Copy link

Hello, the above script doesn't work on apple script 2.8. It returns the following error: "Impossible to get window "Sound" of process "System Preference". (-1728). All of that using Monterey 12.1 and Applescript 2.8. In Big Sur Applescript 2.7 IT WORKS.
Regards

@andreasf
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment