shell icon indicating copy to clipboard operation
shell copied to clipboard

[BUG] Caps_Lock/Num_Lock binds never registered at startup on Lua-configured Hyprland (usingLua unresolved at Component.onCompleted)

Open LucentFox opened this issue 4 months ago • 4 comments

Step 1. Before you submit

  • [x] I have read the above instructions and am sure that this is supposed to be posted here.
  • [x] I've successfully updated to the latest versions (see note below — verified against main directly).
  • [x] I've successfully updated the system packages to the latest.

Note on versions: this is a NixOS install using the flake, pinned to 68821bfd0bcd5a31bb143776f0020f57d89040d2. Rather than rely on the pin being current, I fetched services/Hypr.qml from main and compared: it is byte-identical to the pinned copy in all four relevant places (reloadDynamicConfs, the Component.onCompleted call, the usingLua definition, and the configreloaded handler). So this is present on main as of 2026-08-05.

Step 2. Version info

Version info
$ caelestia -v
Packages: not on Arch

Dots: not installed

Shell: version helper not available

Quickshell: not in PATH

caelestia -v cannot report anything useful on a non-Arch, non-caelestia install deployment, so here are the actual pinned revisions from the flake lock:

caelestia-shell   1.0.0   rev 68821bfd0bcd5a31bb143776f0020f57d89040d2
caelestia-cli             rev 1a228f9b5566a6e8777a78b086284390357e3640
quickshell        0.3.0   rev 43d4fa9e883cb03239b3d578c9c57070f4fbd281
hyprland          0.56.0  rev 78e2f9b6d17c11100f60c1316b8824ef10a10af3

Hyprland is configured in Lua (~/.config/hypr/hyprland.lua), not hyprlang.

Step 3. Describe the issue

Caps_Lock and Num_Lock are never bound at shell startup on a Lua-configured Hyprland. They only appear after the first hyprctl reload. Until then the shell cannot see either key — no toast, and Hypr.capsLock / Hypr.numLock never update.

Cause

services/Hypr.qml branches on usingLua:

readonly property bool usingLua: Hyprland.usingLua        // line 18

function reloadDynamicConfs(): void {                     // line 90
    if (usingLua) {
        extras.batchMessage(['eval hl.bind("Caps_Lock", …)', 'eval hl.bind("Num_Lock", …)']);
    } else {
        extras.batchMessage(["keyword bindlni ,Caps_Lock,global,caelestia:refreshDevices", …]);
    }
}

Component.onCompleted: reloadDynamicConfs()               // line 98

At Component.onCompleted, Hyprland.usingLua has not resolved yet, so the else branch runs. On Hyprland 0.56 the hyprlang keyword interface no longer exists:

$ hyprctl keyword bindlni ,Caps_Lock,global,caelestia:refreshDevices
unknown request

batchMessage discards the reply, so nothing surfaces the failure.

The configreloaded handler (line 134) calls the same function later, by which time usingLua is true — which is why a reload fixes it, and why it works for the rest of the session but breaks again at the next login.

It is not a compositor-readiness race

The obvious explanation is that the shell starts before Hyprland is ready. It doesn't. Against a fully settled compositor:

systemctl --user stop caelestia.service
hyprctl reload                        # → 64 binds
systemctl --user start caelestia.service
                                      # → 64 binds. Still 64.

The registration is inert every time, not only during login. The unresolved property is the cause.

Reproduction

  1. Hyprland 0.56 with a Lua config; caelestia-shell started as a user service.
  2. Log in, then before doing anything that reloads the compositor:
    hyprctl binds -j | jq 'map(select(.key=="Caps_Lock")) | length'   # → 0
    
  3. Press Caps Lock — no toast, no indicator change.
  4. hyprctl reload
  5. Same query → 1. Caps Lock now works, and keeps working until the next login.

This is easy to miss, because any workflow that touches display settings runs hyprctl reload and silently fixes it for the session.

Logs — the workaround unit observing it at a real login

I run a small unit that checks for the binds and reloads if they are missing. Its log shows the timing clearly:

12:06:17.122  Started Caelestia Shell Service
12:06:17.125  Starting Re-register caelestia's Caps/Num lock binds…
12:06:19.259  lock keys bound after reload (attempt 2)

Note the first reload attempt fails and the second succeeds — the shell's QML is not yet listening for configreloaded about 1.4 s after the service starts.

Suggested fixes

  1. Wait for the property. Register from a handler on Hyprland.usingLua changing, or re-run reloadDynamicConfs() once it resolves, instead of reading it during Component.onCompleted.
  2. Check the IPC reply. batchMessage discarding unknown request is what turns a wrong branch into a silent no-op. This is the fix I'd argue for hardest — it's why the bug went unnoticed, and it would catch the whole class.
  3. Drop the hyprlang branch if hyprlang keywords are unsupported on every Hyprland version the shell targets. A fallback that cannot succeed is worse than none, because it reads as coverage.

Happy to test a patch or open a PR if you'd like — just say which approach you prefer.

LucentFox avatar Aug 05 '26 18:08 LucentFox

Drop the hyprlang branch if hyprlang keywords are unsupported on every Hyprland version the shell targets. A fallback that cannot succeed is worse than none, because it reads as coverage.

While I can't confirm or test this further currently since I don't have a nix install (and this doesn't seem to occur on Arch), I will note that hyprlang support won't be dropped for now. We plan on retaining hyprlang support until hyprland drops it (likely within 0.57 if not sooner), since while the dots have been migrated to lua you don't technically have to use the dots if you're using the shell.

dxnnv avatar Aug 06 '26 17:08 dxnnv

(and this doesn't seem to occur on Arch)

You don't know what you're talking about. I use Arch too, and this problem exists in Arch as well. I just tested it on the main branch and got the same issue

I remember taking this dependency into account when I migrated the shell to Lua, but hyprextras might have been changed afterwards by someone else.

As a quick workaround, adding a Timer seems to fix it for now. Or simply invert the condition in the reloadDynamicConfs function in the Hypr.qml file so that it doesn't get stuck at false. Of course, this applies if you're using Lua syntax.

For the actual fix, I’d drop the dependency on the value coming from Quickshell and make HyprExtras detect the config provider itself through its existing socket. It should also re-check on every configreloaded event, so if there’s a race condition during startup, it can fix itself afterwards.

This also eliminates some of the problems that might arise in the future.

Mestane avatar Aug 16 '26 16:08 Mestane

This may actually be fixed now after ad8dca0. Could either of you verify if this works now for you if you're using the -git package or a manual install? @LucentFox @Mestane

dxnnv avatar Aug 16 '26 21:08 dxnnv

This may actually be fixed now after ad8dca0. Could either of you verify if this works now for you if you're using the -git package or a manual install? @LucentFox @Mestane

Confirmed fixed. I'm on NixOS building from main via the flake, at 16fb637 (includes ad8dca0). I stopped the shell and ran hyprctl reload so the Caps_Lock/Num_Lock binds were gone, then started the shell on its own: both binds were back within 2s, and the Caps/Num Lock toasts show. Before the fix they stayed missing until the next reload. I've removed my workaround.

One side effect: the binds now stack when the shell restarts without a Hyprland reload. The old binds stay registered and onUsingLuaChanged sdds another pair, so hyprctl binds went from 1 → 2 → 3 of each over two shell restarts, and hyprctl reload brings it back to 1. It's harmless so far since the toast still shows, but each restart adds another pair. Thanks for the fix!

LucentFox avatar Sep 10 '26 23:09 LucentFox