Created
April 4, 2022 13:18
-
-
Save numbcoder/68d211754f010cfb90153dbcf544e806 to your computer and use it in GitHub Desktop.
Connect to AirPods for hammerspoon
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
-- connected to AirPods by name | |
function connectToAirPods(name) | |
local current = hs.audiodevice.defaultInputDevice() | |
if current and current:name() == name then return true end | |
local device = hs.audiodevice.findOutputByName(name) | |
if device == nil then | |
hs.alert.show(name.." is not connected") | |
else | |
return device:setDefaultOutputDevice() | |
end | |
end | |
-- keymap | |
hs.hotkey.bind({"ctrl", "cmd"}, "p", function() connectToAirPods("Tim’s AirPods Pro") end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment