I'm trying to setup a button to toggle the Mac Sound Output between ProTools and Carbon Interface. I'm attempting to do this with a script but it is not working. Can you advise a better way to do this?
Here is the code I'm using:
//Calling command "System Preferences_OPEN APP" from package "Applications" (installed from user/pkg/version "iDVCzKgxCsRMTzLbu8IWNKxYpvh1/ckag2danb00012e101wex822n/cklsmy1k1000sdc103cvn0wwx")
sf.soundflow.runCommand({
commandId: 'user:clpsyip7j00037610mkw3xvyq:ckag6jkbd0004wk10x76a5zcn',
props: {}
});
sf.ui.app("com.apple.systempreferences").mainWindow.tabGroups.first.scrollAreas.first.tables.whoseDescription.is("sound output devices").first.children.whoseRole.is("AXRow").allItems[1].textFields.whoseValue.is("Carbon | Expanded:Core Audio Primary").first
Linked from:
- Christian Scheuer @chrscheuer2023-12-06 23:02:51.122Z
I would use a Terminal utility for this, since the System Prefs window is not very scriptable.
- Start by installing Homebrew from https://brew.sh/
- Open up Terminal, install the SwitchAudio-OSX utility by running this:
brew install switchaudio-osx
- You can now run the following in Terminal to get a list of available audio outputs:
SwitchAudioSource -a
- And run this to switch to a device:
SwitchAudioSource -s "Device Name"
Once that's installed, you can then call it from SoundFlow like so:
sf.system.exec({ commandLine: `SwitchAudioSource -s "Device Name"` });
Nathan Salefski @nathansalefski
Hey Christian,
The SwitchAudio-OSX utility seems to be working perfectly fine when run in Terminal, but trying to do so from SoundFlow doesn't work. Any ideas as to why that could be?Christian Scheuer @chrscheuer2023-12-07 00:58:22.787Z
You may need to specify the full path to the executable.
Type
which SwitchAudioSource
in Terminal to get its full path, then in SF replace the commandLineSwitchAudioSource
with the full path.Nathan Salefski @nathansalefski
That did the trick!
sf.system.exec({ commandLine: `/opt/homebrew/bin/SwitchAudioSource -s "Device Name"` });
- DIn reply toDanIsrael⬆:Dan Israel @DanIsrael
Thank you both. That works great!