Wednesday, January 14, 2009

Change audio devices via shell script

I searched for a long time for a way to activate Soundflower as part of a script, but I couldn't find any way to do so, short of opening system preferences and using UI scripting to control the settings.

There had to be a better way.

I found SoundSource, but I couldn't find any way to activate it from applescript, even with UI scripting. I asked the developers about scriptability, and after a few emails back and forth, they decided to release the source, which I used to build audiodevice.

Audiodevice
Source

This the basic functionality of SoundSource with a quick and dirty command line interface slapped on. Type "audiodevice help" for usage information. Since I got my Airport express, I haven't had much use for my Soundflower script, but I still regularly use it in conjunction with Proxi to activate my bluetooth headset from the keyboard.