Karabiner-elements: App specific settings possible?

Created on 3 Jul 2017  路  10Comments  路  Source: pqrs-org/Karabiner-Elements

Is there a way to implement App-specific settings to change keys?
Thanks

stale

Most helpful comment

You can copy this example into ~/.config/karabiner/assets/complex_modifications/windows-binding.json

Got to karabiner preferences->complex Modifications->Add rule and press enable on it.

You can modify it to your liking but make sure you run it through a json validator first.

{
  "title": "Windows keys",
  "rules": [
    {
      "description": "swap control/command fix home/end/redo except for iterm2/vim",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "y",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "z",
              "modifiers": [
                "command",
                "shift"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "end"
          },
          "to": [
            {
              "key_code": "e",
              "modifiers": [
                "control"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "home"
          },
          "to": [
            {
              "key_code": "a",
              "modifiers": [
                "control"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "left_command"
          },
          "to": [
            {
              "key_code": "left_control"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "left_control"
          },
          "to": [
            {
              "key_code": "left_command"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "right_command"
          },
          "to": [
            {
              "key_code": "right_control"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "right_control"
          },
          "to": [
            {
              "key_code": "right_command"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        }
      ]
    }
  ]
}

All 10 comments

Looking for this too.
In old karabiner I used that for remote desktop.
In macos I have switched CTRL and CMD with karabiner elements which works fine.
But when i RDP into a Windows machine the mapping will make Windows use CMD for CTRL and vice-verca.
Bascially I'm looking to have CTRL+C etc. to work the same regardless if I'm using macos or RDP into Windows.

it seems supported now

                    {
                        "manipulators": [
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "^com\\.apple\\.finder$"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "description": "Finder Ctrl-; goto location",
                                "from": {
                                    "key_code": "semicolon",
                                    "modifiers": {
                                        "mandatory": [
                                            "left_control"
                                        ],
                                        "optional": [
                                            "caps_lock",
                                            "shift",
                                            "option"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "g",
                                        "modifiers": [
                                            "command",
                                            "shift"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    },

@jixiuf Yes, looks like the conditions section is it. Is there somewhere in the UI we could set this? Or where is the file you are looking at located?

You can copy this example into ~/.config/karabiner/assets/complex_modifications/windows-binding.json

Got to karabiner preferences->complex Modifications->Add rule and press enable on it.

You can modify it to your liking but make sure you run it through a json validator first.

{
  "title": "Windows keys",
  "rules": [
    {
      "description": "swap control/command fix home/end/redo except for iterm2/vim",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "y",
            "modifiers": {
              "mandatory": [
                "command"
              ]
            }
          },
          "to": [
            {
              "key_code": "z",
              "modifiers": [
                "command",
                "shift"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "end"
          },
          "to": [
            {
              "key_code": "e",
              "modifiers": [
                "control"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "home"
          },
          "to": [
            {
              "key_code": "a",
              "modifiers": [
                "control"
              ]
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "left_command"
          },
          "to": [
            {
              "key_code": "left_control"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "left_control"
          },
          "to": [
            {
              "key_code": "left_command"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "right_command"
          },
          "to": [
            {
              "key_code": "right_control"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "right_control"
          },
          "to": [
            {
              "key_code": "right_command"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_unless",
              "bundle_identifiers": [
                "^org\\.vim\\.",
                "^com.googlecode.iterm2"
              ]
            }
          ]
        }
      ]
    }
  ]
}

Yupp, already done it and it works perfectly :-)

This is awesome. Thank you. I have it running in Karibiner elements. Can you please tell me how I would tweak it so that it only works when typing from within Teamviewer?

I was given a solution to switch the command and control keys only using team viewer. It is here:
https://forum.keyboardmaestro.com/t/switching-command-and-control-keys/7721/27?u=cinematree

It looks like there is no way to define "conditions" once so it applies to all manipulators?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings