Switching audio but never to Airpod Maxes
The microphone on my Airpod Maxes sucks. I am not sure if its my headphones being fairly old and used daily for over 1,000 days, or if the microphone is just bad.
The issue is that every time I put my headphones on, the audio input changes to be the Maxes. There is no way to override this behaviour in Mac OS X.
I figured this would be an easy Apple Shortcuts shortcut but it turns out Shortcuts does not support devices being connected as an input. Fortunately, Shortcuts has a huge eco-system of apps that can contribute inputs.
Enter Shortery.
I was able to create a shortcut in Shortery that triggers when my Maxes are connected.
It turns out Apple Shortcuts also doesn't have controls over audio inputs/outputs. However, there is a brew script that can provide this — SwitchAudio.
I then wrote a terminal script that switches the audio:
#!/bin/zsh
# Capture the output of the command
output=$(/opt/homebrew/bin/SwitchAudioSource -a)
# Check if "Sutdio Display" is attached
if echo "$output" | grep -q "Studio Display Microphone"; then
# Run the "x" command if "blah" is found
/opt/homebrew/bin/SwitchAudioSource -t input -s 'Studio Display Microphone'
else
# If not attached, use the Macbook mic
/opt/homebrew/bin/SwitchAudioSource -t input -s 'MacBook Pro Microphone
fi
I then trigger this shell script via Shortcuts. Essentially, when my Airpod Maxes are connected:
-
Switch audio input to my Monitor (if monitor connected)
-
Switch audio input to my MacBook Pro (if no monitor connected)
Simple, here is the Shortery automation:
and here is the Shortcuts automation: