DEV Community

Rafał Sroka
Rafał Sroka

Posted on

2 1

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

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 👀

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs