to.set_variable

set_variable defines and updates the variable value.

{
    "to": [
        {
            "set_variable": {
                "name": "variable name",
                "value": variable value
            }
        }
    ]
}
Name Required Description
name Required Target variable name.
value Required Target variable value.

Available types of value

Type Example value Available since
integer 0,1,2,… Karabiner-Elements 11.0.0
boolean true, false Karabiner-Elements 14.4.20
string “layer1”, “layer2” Karabiner-Elements 14.4.20

Examples

{
    "set_variable": {
        "name": "mode_flag",
        "value": 42
    }
}
{
    "set_variable": {
        "name": "mode_enabled",
        "value": true
    }
}
{
    "set_variable": {
        "name": "layer_name",
        "value": "layer1"
    }
}

Confirm the current variable values

You can see the current variable values by EventViewer > Variables.

eventviewer-variables@2x.png