I have a Hammerspoon script which contains a whitelist of audio in and out devices, and I use this to switch between the audio devices I want to use. This works well with directly connected devices, but has some bugs with normal bluetooth devices, and doesn’t work at all with AirPods.
So I’m looking for a new solution. Something that with one simple [shortcut|click|something I can automate] will allow me to switch audio so that whatever I’m listening actually comes out through what I want to listen to it with.
(Hammespoon script included for fun)
outputArray = {}
-- outputArray["Speaker"] = "Impresario"
outputArray["Astro A50 Game"] = "Astro A50"
outputArray["Built-in Output"] = "Internal Speaker"
outputArray["MacBook Pro Speakers"] = "Internal Speaker"
outputArray["FiiO USB DAC-E10"] = "FiiO"
outputArray["Logitech G930 Headset"] = "G930"
outputArray["Tom’s AirPods Pro"] = "Airpods"
outputArray["WH-1000XM3"] = "Sony"
-- outputArray["CalDigit Thunderbolt 3 Audio"] = "Thunderbolt"
outputArray["Jabra Link 380"] = "Jabra"
inputArray = {}
-- inputArray["CalDigit Thunderbolt 3 Audio"] = "Thunderbolt"
inputArray["WH-1000XM3"] = "Sony"
inputArray["MacBook Pro Microphone"] = "Internal Microphone"
inputArray["Tom’s AirPods Pro"] = "Airpods"
inputArray["Jabra Link 380"] = Jabra
current_output = hs.audiodevice.defaultOutputDevice()
current_input = hs.audiodevice.defaultInputDevice()
function switch_output()
for _, device in pairs(hs.audiodevice.allOutputDevices()) do
if device and device ~= current_output and outputArray[device:name()] then
hs.alert.show("Audio out: " .. outputArray[device:name()])
current_output = device
device:setDefaultOutputDevice()
break
end
end
end
function switch_input()
for _, device in pairs(hs.audiodevice.allInputDevices()) do
if device and device ~= current and inputArray[device:name()] then
hs.alert.show("Audio in: " .. inputArray[device:name()])
current = device
device:setDefaultInputDevice()
break
end
end
end