deweller / switchaudio-osx

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

Enable to use uid to switch to an output device with a shared name. #55

Closed splitrr closed 1 year ago

splitrr commented 1 year ago

Hi,

Love the utility but I'm having troble switching output to a particular monitor: I have two monitors with the same name:

SwitchAudioSource -at output -f json                                             
{"name": "BenQ EW3270U", "type": "output", "id": "126", "uid": "AppleGFXHDAEngineOutputDP:30001:0:{D109-7950-00005445}"}
{"name": "BenQ EW3270U", "type": "output", "id": "142", "uid": "AppleGFXHDAEngineOutputDP:30001:1:{D109-7950-00005445}"}
{"name": "CalDigit USB-C HDMI Audio", "type": "output", "id": "136", "uid": "AppleUSBAudioEngine:CalDigit, Inc.:CalDigit USB-C HDMI Audio:2141000:2"}
{"name": "MacBook Pro Speakers", "type": "output", "id": "108", "uid": "BuiltInSpeakerDevice"}
{"name": "Microsoft Teams Audio", "type": "output", "id": "49", "uid": "MSLoopbackDriverDevice_UID"}

**I get**
SwitchAudioSource -u AppleGFXHDAEngineOutputDP:30001:0:{D109-7950-00005445}
Could not find an audio device with UID "AppleGFXHDAEngineOutputDP:30001:0:{D109-7950-00005445}" of type output.  Nothing was changed.

**Goes to the wrong monitor**
SwitchAudioSource -s "BenQ EW3270U"

Any pointers?

PS Using the ID, e.g. 126 works but breaks when I reconnect the laptop as the ID changes.

Many thanks

deweller commented 1 year ago

Thanks for reporting this. I just merged #53 and submitted version 1.2.2 to homebrew which should fix this.

splitrr commented 1 year ago

Great thx.