DEV Community

Rafał Sroka
Rafał Sroka

Posted on

Loading locally created rule configuration to Karabiner

I use a vintage left-handed vertical mouse. It has extra buttons that I have always mapped to Copy and Paste shortcuts to limit moving my hand back to the keyboard.

Alt Text

There were always problems with the mouse driver for macOS. At some point, the driver from Evoluent stopped working whatsoever and I had to look for an alternative. I'd been already using Karabiner to configure custom keyboard mappings so I decided to give it a go and add mappings for the mouse.

In order to create such mappings I had to configure a custom configuration rule and add it to Complex Modifications in the Karabiner preferences.

The following config maps button 4 and button 6 of the mouse to key combos CMD + C and CMD + V.

{
  "title": "Mouse button 4 to copy, button 6 to paste",
  "rules": [
    {
      "description": "Maps mouse button 4 to CMD+C (copy), button 6 to CMD+V (paste).\n",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "pointing_button": "button4"
          },
          "to": [
            {
              "repeat": false,
              "key_code": "c",
              "modifiers": [
                "left_gui"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "pointing_button": "button6"
          },
          "to": [
            {
              "repeat": false,
              "key_code": "v",
              "modifiers": [
                "left_gui"
              ]
            }
          ]
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Karabiner does not have an easy way of adding custom rules via the UI. There is an UI to import from the Internet or generate rules configuration via online tools.

There is a way to make Karabiner use the locally created rule though. Here's how to do it:

  1. Copy the json file with the rule to ~/.config/karabiner/assets/complex_modifications. Name of the file does not matter. Do it by drag and dropping in Finder or use shell:
cp public/json/rule_configuration.json ~/.config/karabiner/assets/complex_modifications
Enter fullscreen mode Exit fullscreen mode
  1. Import rules from Karabiner-Elements Preferences. Karabiner-Elements Preferences > Complex Modifications > Rules > Add rule

I used Karabiner-Elements version 13.5.0.
The mouse I use is Evoluent Vertical Mouse 4 (left-handed version).

Top comments (0)