Controlling Caps Lock LED during Complex Modifications

Author: revolterCreated May 18, 2023Updated Sep 15, 2026
Labelsenhancement

Revival of #1257.

Having this complex modification:

json
{
    "title": "Caps Lock useful",
    "rules": [
        {
            "description": "Caps Lock to mute/unmute",
            "manipulators": [
                {
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock"
                    },
                    "to": [
                        {
                            "set_variable": {
                                "name": "is_caps_lock_active",
                                "value": 1
                            }
                        },
                        {
                            "shell_command": "osascript -e 'tell application \"System Events\" to set volume input volume 100'"
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "is_caps_lock_active",
                            "value": 0
                        }
                    ]
                },
                {
                    "type": "basic",
                    "from": {
                        "key_code": "caps_lock"
                    },
                    "to": [
                        {
                            "set_variable": {
                                "name": "is_caps_lock_active",
                                "value": 0
                            }
                        },
                        {
                            "shell_command": "osascript -e 'tell application \"System Events\" to set volume input volume 0'"
                        }
                    ],
                    "conditions": [
                        {
                            "type": "variable_if",
                            "name": "is_caps_lock_active",
                            "value": 1
                        }
                    ]
                }
            ]
        }
    ]
}

causes the Caps Lock key's LED to stop working.


I also tried adding

json
{
    "key_code": "caps_lock"
}

under the to key, with the idea that the complex modification would then act as a proxy. But instead, you now have to press caps lock twice to toggle the LED once.

Source: pqrs-org/Karabiner-Elements