Have you ever tried to ask Siri to connect to your AirPods? Alas, it can't. So until that day arrives, here's a script solution for you!
This Alfred workflow runs an osascript that toggles the connectivity of your AirPods on your Mac. It offers a keyword or Hotkey trigger to initiate it, which you can customise however you want.
The original script credit goes to Josh Johnson for his AppleScript that either connects or errors out responsibly. His excellent instructions and suggestions for other methods of triggering it can be found over on Medium.
The original functionality has been extended with:
- a check for the current Connect/Disconnect status, which then toggles the connectivity based on this state.
- System notifications which provide further confirmation of connection status.
- The applescript was fully incorporated into an osascript embedded within an Alfred Workflow (instead of launching it externally) and later to a python script.
If you're not an Alfred user you can still launch the Applescript app through many other methods such as adding it to your Dock, using Apple's Spotlight or support some other great indie developers with: QuickSilver, BetterTouchTool, LaunchBar, Keyboard Maestro. Just download this entire Github package and unzip.
- Alfred App v3+ – install the latest free version of Alfred.
- Alfred Powerpack – buy the Powerpack (required to use workflows such as this and unlock all the other awesome potential in Alfred)
- Toggle Airpods workflow – direct download of this script.
Assuming you meet the requirements above:
- Double-click the workflow you downloaded above to install in Alfred.
- Review the workflow's Keyword and Hotkey and customise to your liking. I use a Hyper Key trigger 1
- run setairpods and select your device
-
setting
- Keyword:
setairpods
- Keyword:
-
run
- Keyword:
airpods
- Hotkey:
CONTROL+OPTION+COMMAND+SHIFT+P
orCAPS LOCK+P
(if you have a Hyper Key).
- Keyword:
- Customise the name of your device in the script as indicated below.
- Move to your ~/Library/Scripts folder or wherever your launcher of choice looks for scripts. It's also possible to open the ToggleAirPods.app with Apple Script Editor and copy and paste the code directly in to the appropriate place of your launcher's command.
1: All you need to do is install Karabiner, a free keyboard customiser then enable the Complex Modification example called: Change caps_lock to command+control+option+shift
. Inspired by Brett Terpstra's Hyper Key idea.
- v1.4 2020-05-13
- update locale text in setdevice script for EN-US and use it as fallback if no other locations match (Thanks to @jhseodev)
- feel free to submit any other localisations that work for you!
- v1.3 2019-09-15
- keep current window focus on Setairpods script as well
- added localisation in Mandarin [Raphus-cucullatus]
- v1.2 2019-09-13
- Removed now unnecessary script line that stole focus away from the previous window. [Thanks to Raphus-cucullatus!]
- Relocated animated gif instruction with repo.
- Recompiled the original applescript for 64bit in case other than Alfred users still want to delve in to adapting it.
- v1.1 2018-12-28 Script restructuring, replaced manual device naming in script with dedicated setairpods command. Korean localisation. Anymore localisations most welcome! [novelview9]
- v1.0 2018-01-05 Initial release
- rename more generically as it really works for any bluetooth audio device now.
- Add support for ASCII characters outside of core 128 character range. I like to use an Emoji character on all my devices these days to visually set them apart from other people's in the vicinity. 🤗
- More localisations
- More informative notification besides just complete. i.e. differentiate between Connected/Disconnected.