deweller / switchaudio-osx

Change the audio source for Mac OS X from the command line.
Other
1.19k stars 88 forks source link

Toggle Switch #30

Closed becauseim closed 3 years ago

becauseim commented 3 years ago

I have two quick actions to turn on separate devices, but I would like to have one action to switch between the two devices. how do I do this?

Снимок экрана 2021-03-20 в 20 06 11
zuckschwerdt commented 3 years ago

I use something like [ "$(AudioSwitcher -c)" = "Built-in Output" ] && AudioSwitcher -s "DisplayPort" || AudioSwitcher -s "Built-in Output"

becauseim commented 3 years ago

I use something like [ "$(AudioSwitcher -c)" = "Built-in Output" ] && AudioSwitcher -s "DisplayPort" || AudioSwitcher -s "Built-in Output"

Thank you! But i don't understand how to use it. My example is based on this one

zuckschwerdt commented 3 years ago

It's just the Shell Script, like the one you already have. E.g. replace

/usr/local/bin/SwitchAudioSource -t output -s 'Cayin N3Pro'

with

[ "$(/usr/local/bin/SwitchAudioSource -c)" = "Built-in Output" ] && /usr/local/bin/SwitchAudioSource -s "Cayin N3Pro" || /usr/local/bin/SwitchAudioSource -s "Built-in Output"

or, simpler, maybe just use

/usr/local/bin/SwitchAudioSource -n

which will switch to each next audio output available (A -> B -> ... -> A).

becauseim commented 3 years ago

Thank you! Unfortunately, an error comes out when calling a quick action.

Снимок экрана 2021-03-20 в 23 39 35

/usr/local/bin/SwitchAudioSource -n

this option is not suitable because you need to switch between two devices out of three (without built-in macbook speakers)

becauseim commented 3 years ago

my goal is to switch between two external output devices with one keyboard shortcut

zuckschwerdt commented 3 years ago

Try in Terminal.app to see what's wrong.

deweller commented 3 years ago

Closing this because it is not an issue directly related to switchaudio-osx.

I hope you are able to resolve your problem with your bash script.

gianpaj commented 1 year ago

If anybody lands here, I wrote this bash script to toggle between 2 audio interfaces with Alfred.

https://gist.github.com/gianpaj/6334e6a4cd1f9fe48b58c1e7b8ccd5a2

Though this Alfred Workflow is readily done and works great :) https://github.com/dkarter/alfred-switch-audio