Is it possible to connect to AirPods Pro via keyboard shortcut?
문제
I want to connect to my AirPods Pro on mac (Big Sur 11.1) using keyboard shortcut. I find it tedious to manually choose the top-right icon on the menu bar and click 'connect', but at the same time I don't want to make the pairing automatic since not always do I want to connect to my mac, such as while I play the music on my iPad.
So I want to connect to it via keyboard shortcut. Is it possible? It's fine to use 3rd-party apps such as Hammarspoon or Karabiner-Elements, though I could not find a way to connect to the AirPods.
해결책
Karabiner + Blueutil Solution
I do something like this using a bluetooth cli tool named blueutil. Here is a complex modification you could use in Karabiner.
{
"title": "Bluetooth Connect",
"rules": [
{
"description": "Connect to AirPods",
"manipulators": [
{
"from": {
"key_code": "a",
"modifiers": {
"mandatory": ["fn"]
}
},
"to": [
{
"shell_command": "/usr/local/bin/blueutil -p 1; /usr/local/bin/blueutil --connect \"AirPods Pro\""
}
],
"type": "basic"
}
]
}
]
}
+ Goku
Goku is a tool for more easily managing your karabiner configuration. I use this to manage mine. I have configured Karabiner to use F10 as a "audio layer"/modifier key for audio related mappings. If you learn a little about how Goku works, you can check out my configuration if you want to implement something like this for yourself.