Skip to content

This Alfred workflow includes 2 scripts that set your AirPods name then toggles the connectivity to your Mac. A standalone AppleScript app is included for adaptation to other launchers.

License

Notifications You must be signed in to change notification settings

jasonshanks/alfred-workflow-toggle-airpods

Repository files navigation

Alfred Workflow – Toggle AirPods

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.

Extended features

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.

Requirements

  1. Alfred App v3+ – install the latest free version of Alfred.
  2. Alfred Powerpack – buy the Powerpack (required to use workflows such as this and unlock all the other awesome potential in Alfred)
  3. Toggle Airpods workflow – direct download of this script.

Installation: Alfred

Assuming you meet the requirements above:

  1. Double-click the workflow you downloaded above to install in Alfred.
  2. Review the workflow's Keyword and Hotkey and customise to your liking. I use a Hyper Key trigger 1
  3. run setairpods and select your device

Assigning bluetooth device with the setairpods command

Commands

  • setting

    • Keyword: setairpods
  • run

    • Keyword: airpods
    • Hotkey: CONTROL+OPTION+COMMAND+SHIFT+P or CAPS LOCK+P (if you have a Hyper Key).

Installation: other launchers or directly as an Applescript

  1. Customise the name of your device in the script as indicated below. Customise device name here.
  2. 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.

Contributors

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.

Release notes

  • 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

Todo

  • 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.

About

This Alfred workflow includes 2 scripts that set your AirPods name then toggles the connectivity to your Mac. A standalone AppleScript app is included for adaptation to other launchers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published