Created
March 30, 2024 05:37
-
-
Save Trung-DV/df02ffc3bb1b910b6d32eeb54e269311 to your computer and use it in GitHub Desktop.
Hammerspoon script to change Microphone from AirPods to MacBook Microphone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local MICROPHONE_DEVICE_NAME = "MacBook Pro Microphone" | |
function detectAirPods(event) | |
if event ~= "dOut" and event ~= "dIn " then | |
return | |
end | |
local device_name = hs.audiodevice.current().name | |
if device_name:find("AirPods") == nil then | |
return | |
end | |
local microphone = hs.audiodevice.findInputByName(MICROPHONE_DEVICE_NAME) | |
if (microphone ~= nil) then | |
microphone:setDefaultInputDevice() | |
-- hs.notify.show("AirPods", "","Use "..MICROPHONE_DEVICE_NAME) | |
end | |
hs.notify.show("Mic","Current device",hs.audiodevice.defaultInputDevice():name()) | |
end | |
hs.audiodevice.watcher.setCallback(detectAirPods) | |
hs.audiodevice.watcher.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment