deweller / switchaudio-osx

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

Support Device ID and Device UID #25

Closed nbolender closed 3 years ago

nbolender commented 4 years ago

Merges commits from @m3g0byt3 that added support for displaying and setting by device ID.

Also adds support for Device UID. See below for why this is necessary in some situations:

The device ID is not consistent when unplugging and re-plugging an external audio source (it is some sort of counter). So this presents a problem when you want to choose a specific device.

macOS exposes a UID string for each audio device. The format of this string is a black box. For example, for built-in devices it is a simple string like BuiltInSpeakerDevice, but for a DisplayPort device it may be something like AppleGFXHDAEngineOutputDP:30001:0:{AD19-43B2-5257260B}. In the second case, the same device may appear as AppleGFXHDAEngineOutputDP:30001:1:{AD19-43B2-5257260B} if it is the second DisplayPort device currently plugged in.

So to support switching inputs by UID, this PR checks against a substring and it is left to the user to find the unique portion of the string. For the above example, running SwitchAudioSource -u AD19-43B2-5257260B always selects the appropriate device.

fharper commented 3 years ago

Any update on merging this PR? I compiled it, but just wondering since it seems ready to merge and would be nice for others to have it :D

deweller commented 3 years ago

Thanks for the friendly reminder. I'll have some time next week to look over this and I will merge it if all looks good.

derekjobst commented 3 years ago

Looking forward to this!

pormerod commented 3 years ago

I would sincerely appreciate having these features.

deweller commented 3 years ago

I hear you. Apologies for the delay.

deweller commented 3 years ago

Great work. Thanks.

workmanw commented 2 years ago

Thanks for this great addition. I wonder if the the -a flag should support listing the device ID or maybe a new flag. It took me a while to figure out how to actually determine my device ID.

nbolender commented 2 years ago

@workmanw it is available when using the CLI or JSON formats. In this PR I had it displaying in the default format (human), but it was later changed to show only the device name.

Maybe this note should at least be added to the readme.

workmanw commented 2 years ago

@workmanw it is available when using the CLI or JSON formats. In this PR I had it displaying in the default format (human), but it was later changed to show only the device name.

Maybe this note should at least be added to the readme.

Oh perfect! Yea I didn't realize there were different formats. I think a note in the README would be perfect.