deweller / switchaudio-osx

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

Functionality to blocklist audio devices #59

Open buzhidaoist opened 1 year ago

buzhidaoist commented 1 year ago

Some audio devices that are automatically listed in macOS may be undesirable, e.g. external display audio outputs that are never used (example).

I mostly run SwitchAudioSource -n with a shortcut that I scripted to run repeat calls to the utility while the current audio source is in a predefined blocklist (e.g. {"DELL U2720Q", ... }) so it skips them when cycling. However, this doesn't stop the behavior of defaulting to blocklisted devices when the current device is disconnected. I'm not sure how to fix this aside from setting a cron job to repeatedly check the current audio device and cycle if blocklisted.

Would it be useful to add blocklisting/allowlisting functionality into the utility itself? I personally would mainly use it in cycling with -n, though potentially it can help cleaner scripting with the utility as well. If so, the following decisions come to mind:

I'd be happy to try implementing this myself! If this idea seems unnecessary, I'd appreciate any suggestions on how to better handle this issue.