How to Connect Your AirPods to Your Mac with a Keyboard Shortcut

Josh Johnson
4 min readSep 22, 2017

On the first day that I owned my Apple AirPods, they would connect to my Mac as soon as I put them in my ears. They don’t do that anymore. Now, I have to click on the bluetooth menu in the menu bar and connect them manually… each time I take them out of the case. This is no good. I’m far too lazy to carry on like this, so I figured out how to connect my AirPods with a keyboard shortcut. Read on to learn how.

This is Easier Than You Think

Fair warning: if you scroll through the steps below, this seems like a long process, but that’s just because I went into every little detail. If you know your way around a Mac, this will take five minutes or less. All you have to do is copy and paste a script, change one line to add in the name of your AirPods, make sure the script has accessibility permissions, and then assign the script a keyboard shortcut. That’s it. If you know how to do that stuff, you can close this tab now and get to it.

Part 1: AppleScript

Don’t be afraid! You don’t have to actually write any AppleScript. We can steal everything we need from Andrew Burns, who created and shared an awesome little script to connect to any bluetooth headphones. Thanks Andrew!

1. Open Script Editor

This is the application for creating and running AppleScripts. It is found in your Utilities folder, but you can just use Alfred or Spotlight to bring it up quickly.

Toss in the name of your AirPods and you’re done

2. Paste in Andrew’s Script and Customize

You can do this. To begin, just copy Andrew’s script, then paste it into Script Editor. To make this work for your AirPods, you’ll need to edit a single line of his code. Find this bit: tell (menu item "SX-991" of menu 1).

Replace SX-991 with the name of your AirPods. It’s important to note that you have to get the name of your AirPods precisely correct, down to the apostrophe. This little gem tripped me up and it will throw an error for you too if you don’t get it right:

Syntax matters!

3. Save As an Application

You’re done with the ApplScript part! See, I told you it was easy. Now save your work. In the save dialog, choose “Application” as your File Format. I called my application, “ConnectToAirpods” and dropped it into my Applications folder.

Save as an Application

Part 2: Accessibility Preferences

If you run your script, you’ll notice that it won’t actually work. That’s because you have to give it permission to control your computer. To fix this, do the following:

  1. Go to “Security & Privacy” in System Preferences
  2. Click the little lock to make changes.
  3. Select “Accessibility” from the list of items on the left.
  4. Hit the little + button
  5. Find your app and add it

Part 3: Create the Keyboard Shortcut

You now have the key component: an app that will connect your Mac to your AirPods. Now for the tricky part: how do you launch an app with a keyboard shortcut? There are quite a few ways to do this. Pick your poison:

  1. Services hack (written by yours truly way back in 2012… I think it still works). Difficulty: super nerd. It’s a lot of hassle, but doesn’t require any third party tools.
  2. Install a free keyboard shortcut launcher like Snap. Difficulty: n00b. Anyone can do this.
  3. Build a quick Alfred workflow. Difficulty: moderate. You’ll need the Alfred Powerpack, which isn’t free. That being said, Alfred is amazing and the team behind it is friendly and hardworking. I think you should use Alfred and buy the Powerpack. Supporting great app developers is good for your soul.

For those that choose the Alfred route, here’s how it works…

1. Create a Workflow:

Open Alfred’s Preferences and go to the Workflow tab. Create a new workflow called Connect to AirPods.

2. Add a Hotkey trigger

Control-click on the worfklow canvas and select Triggers > Hotkey. Choose a keyboard shortcut to launch your app and hit save.

3. Add a Launch App Action

Click and drag from your trigger and select Actions > Launch Apps / Files. Then choose your application.

Your finished worfklow should look like this

You Did It!

Well done. I award you 100 nerd points. Apple didn’t give you the feature you wanted so you built it yourself. You’re a go getter.

--

--