Hey guys, does anyone have a script that can switch sound outputs on macOS? I want to be able to switch over to my Airport Express-connected speakers with either a keystroke or a BetterTouchTool gesture, and I assume that I’d need a script to make that happen. (Yes, I know I can just drop down from the sound icon in the menu bar. But I like the keyboard!) Many thanks!
MBP 13" with Touchbar (2016)
Looks like the only way to change audio sources without clicking in the menu bar or opening system preferences is by using CoreAudio, which as far as I know you can’t do with the basic tools, at least not easily. With that said, it looks like some other folks have wanted to do what you’re thinking about and have written applications to solve the problem. Here are a couple options:
Thank you! I will try to work with those scripts. I appreciate the help!
You could do it with a Keyboard Maestro macro.
Trigger the script via macro or do the actual sound output change via macro? I hadn’t seen a way to do the latter in KM. Thanks!
I don’t do it any more as I use Spotify Connect and an Amazon Echo Dot to control the music in my office now, but I used to have a need to switch audio output programmatically on my Mac. I found trying to do it with key presses not exactly reliable and certainly, not palatable to a purer solution.
That’s when I got myself a copy of Porthole by Danger Cove, a little app that allowed me to control some audio switching via AppleScript triggered from Keyboard Maestro. BUT, Porthole is alas no more.
My KM & AS for anyone particularly interested
I had a quick look around and AirFoil by Rogue Amoeba is AppleScriptable. Looking at the details shown, it would seem that a similar option to AppleScript a solution using AirFoil may therefore be viable.
Hope that helps.
This is all great stuff! Thanks! Unfortunately, I’ll have to wait to play around with it… Because, fortunately, I can leave my work computer behind as I get ready for a 2-week vacation!
Thanks for all the tips, everyone. I had seen some of it before on Google searches, but you all have confirmed some things I had suspected. I appreciate it!
Audio Switch for Alfred:
which has detail on some underlying scripts that should be applicable if you’re not using Alfred.
If you’re going through all that you could just record changing the output by clicking the volume icon in the menu bar volume with Automator, save it as a service and assign it a keyboard shortcut.
It’s going to take control of the mouse which is why I was leaning towards something scripted but if that works, then it works.