deweller / switchaudio-osx

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

Add a type of 'all' to set all types in one command #33

Closed gileswells closed 1 year ago

gileswells commented 3 years ago

Full disclosure, I am unsure if this works.

The build succeeds but I haven't dug into figure out where the build outputs to / if it actually does what I hope it will do. This came out of a frustration of my audio switching for output but then not for SMS chimes or for my input mic for Zoom calls.

gileswells commented 3 years ago

@deweller please? I'd try to compile it myself for personal use but I have no idea where to begin on that.

earthtone0ne commented 2 years ago

Came here looking for this feature! I'll try to compile @gileswells branch (I'd have to learn how to do that, too!) but in the meantime, I added these commands to my .bashrc:

local headset_name="Logitech USB Headset"
local internal_speaker="MacBook Pro Speakers"
local internal_mic="MacBook Pro Microphone"
# switch input and output
alias headset='SwitchAudioSource -s "{headset_name}"; SwitchAudioSource -s "{headset_name}" -t input;'
alias speaker='SwitchAudioSource -s "{internal_speaker}"; SwitchAudioSource -s "{internal_mic}" -t input;'
# switch to specified input/output (e.g. `aud h`) or toggle if not specified 
function aud() {
  if [[ ! -f /usr/local/bin/SwitchAudioSource ]] then
    return 1
  fi
  if [[ -z "$1" ]] then 
    SwitchAudioSource -n
    SwitchAudioSource -n -t input
  elif [[ "$1" == "h" ]] then
    headset
  elif [[ "$1" == "s" ]] then
    speaker
  fi 
}
gileswells commented 2 years ago

@earthtone0ne yeah I just run all three under the alias of airpod. Now that I have Monterey installed I just need to see what keyboard shortcut isn't going to mess with the apps I use and I'll drop that into the Shortcuts app rather than have to drop into terminal.

dferg commented 2 years ago

I can confirm this patch works as intended. M1 MBP; Xcode 13.2.1

deweller commented 2 years ago

Thanks for confirming that this works. I'll check this out and merge this week.

gileswells commented 2 years ago

I'll check this out and merge this week.

Thoughts @deweller?

reflexdemon commented 1 year ago

I was always wanting the all feature. Please merge this and kindly publish the build