I like automation, mainly because Bill Gates is right. My working week is a mixture of working from home, the office, meeting rooms, hotels, cafés and client sites. I need a quick and simple way of making sure that my headset, in this case a Plantronics Savi 7xx, is automatically selected on my Mac when I’m at my desk.

So there are few things that need to happen:

  1. You need to install the audio switching app
  2. You need to find the USB device to trigger this workflow
  3. You need to install the trigger into LaunchD
  4. You need to run a bash script to make the audio change

Step 1

Download the audiodevice app from here, and copy to your Applications folder. This application can make changes to where sound is sent or received from, via the command line.

Step 2

You need to switch to the output device you want and then run the command and make a note of the output (it’s in Italics):

host:~ user$ /Applications/audiodevice 
input: Plantronics Savi 7xx
output: Plantronics Savi 7xx
system: Internal Speakers

From this create a bash script like the one below with the right device phrase from before.

Save your automation bash script somewhere, and make sure to run:

host:~ user$ chmod u+x plantronics.sh

Otherwise it won’t run!

Step 3

Now you need to do the clever bit and automate the switch every time your headset is plugged in. To do this you need to open the System Information app and go to USB like below.

System Profiler

Just convert the Product ID to decimal, here; and the Vendor ID to decimal, here.

In the gist below replace two of the keys, idProduct (line 18) and idVendor (line 20), with the decimal numbers you just calculated. Finally in the Program key (line 25) put in the full path to your bash script from Step 2.

You can use LaunchControl or Lingon to make fiddling with the job easier to load into OS X. However if you are comfortable create that .plist file in the LaunchAgents directory for your user.


Now if you are happy with this it needs to be loaded into OS X

host:~ user$ launchctl load ~/Library/LaunchAgents/audioswitcher.plist

You can repeat the process above for as many devices as you like, I’d be interested to know if anyone does use this and what they use this for!!