Macros for Automating Karabiner Elements

Here are two macros that could help to automate Karabiner Elements:

  • Toggle Karabiner Elements
  • Switch Profile

I am not an experienced KE user, but I think automating KE via external macros is much more convenient than baking different application conditions into KE rules.

Please note that these macros will work with the official KE release (currently 14.13.0). In the KE beta track (currently 14.99.…), I have seen significant changes to the background processes that make it unlikely that the Toggle macro will work correctly with any beta version (the Switch Profile macro will – probably – work though).

Toggle Karabiner Elements

Macro Image

Karabiner Elements: Toggle [1.1.2].kmmacros (12.1 KB)

The Quit part of the macro does virtually the same as the "Quit Karabiner-Elements" command from KE's menu bar menu.

The Launch part of the macro works similar to the way KE is launched at login (if set to do so), that is, it activates without opening the Settings window.

Mapped to a hotkey, you can use this for example to quickly deactivate/activate KE when you start working in a specific application.

To build separate Launch and Quit macros, just pick the corresponding Shell Script action (the red actions) and paste it to a new macro. This way you can use it with different Application Triggers, so that KE is automatically activated or deactivated when you switch to these applications.

The "Info" and "Version" comments in the macro give some information about how the macro works and why.

Switch Profile

This macro has had an update since the initial upload. Check the Edit at the end of the post.

Macro Image

Karabiner Elements: Switch Profile [2.0.0].kmmacros (8.9 KB)

Similar to above, you could use this with different Application Triggers: Either with different variable declarations for different applications in an If…Then action, or better, you run the macro from a caller macro for each application where you need a different profile, passing the target profile as a parameter.

The macros have been tested on an Intel Mac only.


  • Jul 8, 2024: Added a note to the post, concerning the compatibility with KE beta versions.

  • Jul 4, 2024: Uploaded new version of the Profile Switcher macro:

    • 2.0.0
      • I discovered that Karabiner comes with a well-working CLI that allows to switch profiles. No need to script the menu :wink:
      • Added notification.
    • 1.0.1
      • Changed the variable value to %TriggerValue%, for setup with a caller macro.