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 

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 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 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 script

Paste the code into the editor.

Airpods 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 script
  • Hit cmd + S to save.
  • Select "Application."
  • Give your application a catchy, memorable name.
Security & 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 settings
  • Select Accessibility on the left side.
  • Click the + sign.
  • Find the new Application you just created and select it.
Automator
  • 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 settings

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

Launch application

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

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

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

Security settings

Go to System Preferences > Keyboard > Shortcuts

New 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 shortcut

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

Security 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!