How To Connect Your AirPods With a Keyboard Shortcut in MacOS

Automate the task that you probably do 10 times per day!
Dayne Dayne (58)
Total time: 10 minutes 
Updated: September 28th, 2020

According to xkcd, if you can shave 5 seconds off of this task each time you perform it, it is worth spending about 12 hours to automate the task (over the course of 5 years):

XKCD comic about saving timeXKCD comic about saving time

We’re big fans of automation and time-saving at howchoo! We’ve made shortcut guides in the past, such as showing you how to auto-hide your dock in MacOS and setting up a Mac mail search box shortcut.

And here’s another great one! If you follow this guide closely, it only takes 10 minutes to automate connecting your Airpods with a keyboard shortcut in macOS!

Apple AirPods ProApple AirPods Pro ×1

Howchoo is reader-supported. When you buy through links on our site, we may earn a small affiliate commission at no cost to you.

activate application "SystemUIServer" tell application "System Events" tell process "SystemUIServer" -- Working CONNECT Script. Goes through the following: -- Clicks on Bluetooth Menu (OSX Top Menu Bar) -- => Clicks on SX-991 Item -- => Clicks on Connect Item set btMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth") tell btMenu click tell (menu item "{{ The name of your airpods here }}" of menu 1) click if exists menu item "Connect" of menu 1 then click menu item "Connect" of menu 1 return "Connecting..." else click btMenu -- Close main BT drop down if Connect wasn't present return "Connect menu was not found, are you already connected?" end if end tell end tell end tell end tell

Thanks @erebusbat for this applescript!

script editorscript editor

Open Script Editor.

It lives in /Application/Utilities/, but just use spotlight (cmd + space).

Click New Document to get a blank editor.

connect to bluetooth scriptconnect to bluetooth script

Paste the code into the editor.

Airpods pro bluetooth menuAirpods pro bluetooth menu

Find the name of your AirPods from your Bluetooth settings. Whatever shows up in the menu is the official name of your AirPods. This name is case sensitive and only allows curly quotes. A curly quote is , not '. A curly quote can be entered using shift + option + ]

Find the section that says {{ The name of your AirPods here }} and replace it with the name of your AirPods.

For me, “Dayne’s AirPods Pro” becomes “Dayne’s AirPods Pro”.

See the completed code below:

activate application "SystemUIServer" tell application "System Events" tell process "SystemUIServer" -- Working CONNECT Script. Goes through the following: -- Clicks on Bluetooth Menu (OSX Top Menu Bar) -- => Clicks on SX-991 Item -- => Clicks on Connect Item set btMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth") tell btMenu click tell (menu item "Dayne’s AirPods Pro" of menu 1) click if exists menu item "Connect" of menu 1 then click menu item "Connect" of menu 1 return "Connecting..." else click btMenu -- Close main BT drop down if Connect wasn't present return "Connect menu was not found, are you already connected?" end if end tell end tell end tell end tell
Save airpods scriptSave airpods script
  • Hit cmd + S to save.
  • Select “Application.”
  • Give your application a catchy, memorable name.
Security & Privacy settingsSecurity & Privacy settings

Go to System Preferences > Security & Privacy

If the settings are locked, click the lock at the bottom left and enter your password to unlock it.

security settingssecurity settings
  • Select Accessibility on the left side.
  • Click the + sign.
  • Find the new Application you just created and select it.
AutomatorAutomator
  • Open the Automator Application which can be found at /Applications/Automator, but again, just use spotlight (cmd + space).
  • Click New Document.
  • Select the cog that says “Quick Action” (it may be called “Service” on older MacOS versions).
Automator workflow settingsAutomator workflow settings

In your new Automator action, under “Workflow receives”, select no input. Make sure it reads “Workflow receives no input in any application.”

Launch applicationLaunch application

On the left side, look for “Launch Application” and double click it.

Add applicationAdd application
  • Click the dropdown, select Other,
  • Find and select your new application.
ActionAction

Hit cmd + save and give your action a catchy name.

Security settingsSecurity settings

Go to System Preferences > Keyboard > Shortcuts

New actionNew action
  • Click Services on the left side and look for your new action under the “General” section. Mine was at the very bottom.
  • Make sure the checkbox is enabled here.
  • Click Add Shortcut next to it.
New shortcutNew shortcut

Think of a memorable keyboard shortcut and enter it. It will appear next to the action.

Security warningSecurity warning

Hit your keyboard shortcut and, voila, things should happen! You may get a security alert the first time you run it, but other than that, you’re all set!

We’re hiring!
Are you a passionate writer? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Leave a Reply

Your email address will not be published. Required fields are marked *