

t type : device type (input/output/system). f format : output format (cli/human/json). Usage: /opt/homebrew/Cellar/switchaudio-osx/1.1.0/SwitchAudioSource -s device_name | -i device_id | -u device_uid (note: the path to the executable is because I installed with homebrew, your path may differ is installing manually (I am assuming readers have some command line experience and understand paths etc in the terminal)) ~ % switchaudiosource Once installed you run switchaudiosource -a to list all the devices Set output2 to 3 -change this to the actual 'line number' of your second output speaker selection

Set selected of row output3 of table 1 of scroll area 1 to trueĪdapted it so it works with Mac OS Monterey (June 2022), assuming you only have 2 outputs (Macbook Speakers & Airplay). Set output3 to 1 -change this to the actual 'line number' of your second output speaker selectionĮlse if (selected of row output2 of table 1 of scroll area 1) then Set output2 to 5 -change this to the actual 'line number' of your second output speaker selection Set output1 to 4 -change this to the actual 'line number' of your first output speaker To and to whoever finds it useful, I adapted it to cycle between 3 devices - Applescript to toggle between two sound outputs by Line number, as they appear in the System Prefs. Set selected of row output1 of table 1 of scroll area 1 to trueĮnjoying This Preset? /K2DesignLab Set selected of row output2 of table 1 of scroll area 1 to true If (selected of row output1 of table 1 of scroll area 1) then Repeat until exists tab group 1 of window "Sound" Tell application process "System Preferences" the rest of the script will use these vales to toggle between the two Set output2 to 2 -change this to the actual 'line number' of your second output speaker selection Set output1 to 1 -change this to the actual 'line number' of your first output speaker Applescript to toggle between two sound outputs by Line number, as they appear in the System Prefs.
