Karabiner-elements: rule-shared conditions

Created on 22 Jul 2017  路  7Comments  路  Source: pqrs-org/Karabiner-Elements

Hi,
thanks for adding custom conditional variables to KE. I am preparing a healfqwerty mirroring script with spacebar switcher. Just thought it would be much simpler if there would be a possibility to specify a condition for the whole rule and its all manipulators instead of defining this per manipulator. E.g. for the halfqwerty script I need to add

  "conditions": [
                                    {
                                        "name": "mirror_mode",
                                        "type": "variable_if",
                                        "value": 1
                                    }
                                ],

for every single manipulator (which should cover all key mappings).
It would be much better if I could just apply this condition to all manipulators with a single instruction.

stale

Most helpful comment

Seems no updates. Anybody else thinks this will be a useful feature?

All 7 comments

Yes, supporting this would be super useful! Otherwise, we might need to have a lot of duplications in the json config.

I've just upoted this feature. I need to remap Function keys only in 2 specific applications - PhpStorm & iTerm2. And here is my rule:

                    {
                        "description": "Functions in iTerm",
                        "manipulators": [
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f1",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f1"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f1"
                                },
                                "to": [
                                    {
                                        "key_code": "f1",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f2",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f2"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f2"
                                },
                                "to": [
                                    {
                                        "key_code": "f2",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f3",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f3"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f3"
                                },
                                "to": [
                                    {
                                        "key_code": "f3",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f4",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f4"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f4"
                                },
                                "to": [
                                    {
                                        "key_code": "f4",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f5",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f5"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f5"
                                },
                                "to": [
                                    {
                                        "key_code": "f5",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f6",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f6"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f6"
                                },
                                "to": [
                                    {
                                        "key_code": "f6",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f7",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f7"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f7"
                                },
                                "to": [
                                    {
                                        "key_code": "f7",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f8",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f8"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f8"
                                },
                                "to": [
                                    {
                                        "key_code": "f8",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f9",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f9"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f9"
                                },
                                "to": [
                                    {
                                        "key_code": "f9",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f10",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f10"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f10"
                                },
                                "to": [
                                    {
                                        "key_code": "f10",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f11",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f11"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f11"
                                },
                                "to": [
                                    {
                                        "key_code": "f11",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f12",
                                    "modifiers": {
                                        "mandatory": [
                                            "fn"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "f12"
                                    }
                                ],
                                "type": "basic"
                            },
                            {
                                "conditions": [
                                    {
                                        "bundle_identifiers": [
                                            "com.googlecode.iterm2",
                                            "com.jetbrains.PhpStorm"
                                        ],
                                        "type": "frontmost_application_if"
                                    }
                                ],
                                "from": {
                                    "key_code": "f12"
                                },
                                "to": [
                                    {
                                        "key_code": "f12",
                                        "modifiers": [
                                            "fn"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    },

That's a big beast

I also ran into the same issue when I tried to have my Dvorak-Qwerty rule applied to English input source only but not CN or JP input sources. I had to do this for every single keystroke:

{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "x",
"modifiers": {
"mandatory": [
"right_shift"
]
}
},
"to": [
{
"key_code": "q",
"modifiers": [
"right_shift"
]
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "c",
"modifiers": {
"mandatory": [
"right_shift"
]
}
},
"to": [
{
"key_code": "j",
"modifiers": [
"right_shift"
]
}
],
"type": "basic"
},

Seems no updates. Anybody else thinks this will be a useful feature?

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.

So this is left without progress... What a pity

Also want this :'(

Was this page helpful?
0 / 5 - 0 ratings