How to set the current audio device to airplay speaker in Apple Script?

964 Views Asked by At

How do I programmatically switch the current output device between built-in speakers on my MacBook Pro and a HomePod Mini (via Airplay) in AppleScript?

1

There are 1 best solutions below

2
Marceli Wac On

This can be done using the Switch Audio Source CLI program and the following script.

I am not affiliated with the switchaudio-osx in any way; I just found it useful for this task.

UPDATE:
I have moved the script to a repository to keep track of the changes needed.