2

Objective

This is more about to confirm if this configuration is correct to do remapping with Karabiner-Elements to remap:

  • caps_lock to left_control if it is in Terminal
  • caps_lock to left_control if it is in Emacs
  • caps_lock to left_command otherwise

Appreciate if someone can confirm if this is good enough, or suggest better/correct ways.

Background

Looking for a way to remap keys in Mac Sierra and found Karabiner-Elements for the purpose, but not many examples and documentations about the syntax of karabiner.json. Hence looking for inputs.

Code

"complex_modifications": {
    "parameters": {
        "basic.to_if_alone_timeout_milliseconds": 1000
    },
    "rules": [
        {
            "manipulators": [
                {
                    "description": "Change caps_lock to left_command in Terminal.",
                    "conditions": [
                        {
                            "bundle_identifiers": [
                                "^com\\.apple\\.Terminal$",
                                "^com\\.googlecode\\.iterm2$",
                                "^co\\.zeit\\.hyperterm$",
                                "^co\\.zeit\\.hyper$"
                            ],
                            "type": "frontmost_application_if"
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "left_control"
                        }
                    ],
                    "type": "basic"
                }
            ]
        },
        {
            "description": "caps_lock to left_control in Emacs",
            "manipulators": [
                {
                    "conditions": [
                        {
                            "bundle_identifiers": [
                                "org\\.gnu\\.Emacs"
                            ],
                            "type": "frontmost_application_if"
                        }
                    ],
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "left_control"
                        }
                    ],
                    "type": "basic"
                }
            ]
        },
        {
            "description": "caps_lock to left_command otherwise",
            "manipulators": [
                {
                    "from": {
                        "key_code": "caps_lock",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "left_command"
                        }
                    ],
                    "type": "basic"
                }
            ]
        }
    ]
}

You must log in to answer this question.

Browse other questions tagged .