Toggle sound output for Caldigit TS2

Hi guys.

I’m a new user of KM and have recently bought a Caldigit Thunderbolt Station 2 for my 5k iMac. I would like to create a macro so I could toggle the sound output of my Mac between the internal speakers and the TS2 with a single key (F5). Can anyone help?
Thanks.
Greetings from Portugal.

Option-click on the menu bar volume icon allows a quickish sound output device change,

but if you need to do it often, and prefer a keystroke to toggle between two particular devices, you could do it with a macro like this (needs Yosemite, for the JXA javascript):

Toggle two SOUND OUTPUT devices.kmmacros (4.8 KB)

(changing the name of the variable for the second device from Elgato to Caldigit)

FWIW the source of the Javascript is at: https://github.com/dtinth/JXA-Cookbook/wiki/Examples#system-preferences

2 Likes