Automation: Switching to your headset without doing anything
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:
- You need to install the audio switching app
- You need to find the USB device to trigger this workflow
- You need to install the trigger into LaunchD
- You need to run a bash script to make the audio change
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.
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!
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.
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.
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!!