Program to Switch Audio Output

I just discovered this command-line gem for switching audio output. Unpack the attached .zip file and put the executable wherever you like to have them. The .zip file also has the Xcode project to generate the executable, in case you are interested in looking at the source. (Warning: it is pretty deep.)

Once you have the executable in place just type AudioSwitcher in the terminal to get a list of options. Then use Execute Shell Script actions to invoke this from KM macros. (Remember to put in the full path.)

I have been switching audio output for a long time using a particularly unreliable GUI script. I am thrilled to have this command-line tool.

AudioSwitcher.zip (107.1 KB)

3 Likes

very useful! I was’t aware that this thing existed :slight_smile: Thanks!

Me either, and I’ve been looking for years.

1 Like

Any chance to tell me how to install this tool please? I haven't got a clue. Thank you!

  1. Copy and paste this command into Terminal to install Homebrew, as per the instructions on the Homebrew website:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  1. Copy and paste this command into Terminal once Homebrew is installed, as per the instructions on the switchaudio-osx GitHub page.

brew install switchaudio-osx

And that's all there is to it.

2 Likes

I know it may seem obvious to most, but I really didn't know, thank you kindly for that, I managed and it works, thank you!

1 Like

When I use the command in Terminal, works without a problem, but when I use it in Keyboard Maestro, with the Action "Execute Shell Script" it gives me error "Command not found". Been reading for the last 2 hours all the tutorials and manuals and can't figure out what I am doing wrong.

29

This can be resolved by creating/editing KM's ENV_PATH variable, as per these instructions, or by including the full path to switchaudio-OSX in the "Execute Shell Script" action, which is what I've done myself in this case:

image

2 Likes

You Sir are a :star:! If you ever happen to be in Dublin, Ireland, I'm buying you a few :beer:! Thank you very much, appreciated!

1 Like

I found that switchaudio-osx is a great tool (thanks for sharing it in your post), however, it does not seem to function for my Homepod or other AirPlay devices. Thus I created a macro named Set Sound Output. It employs AppleScript that automates the macOS User Interface. Unlike you, I’ve not found this method unreliable.

1 Like

Hey Jim! Sorry to resurrect an old thread, but quick question... did you have issues with AirPods, or just AirPlay devices?

When I encountered the problem with AirPlay devices I did not own AirPods. And since, I've not done any additional testing.

I shared a macro Set Sound Output in another thread; it works with all devices, AirPods included. (I now own a pair. :grinning:) The macro also works with multiple versions of macOS.