fix(keyboard): isolate new-keyboard layout to its own device

The interactive new-keyboard picker applied the chosen layout with
`hyprctl switchxkblayout <device> <index>`, which flips the *shared*
layout for every keyboard without its own per-device config — so picking
a layout for an external board dragged the built-in keyboard along, and
the change stuck after unplug (it's global state, not device-bound).
Compounding it, the candidate `keyboard.layouts` pool was merged into
`input.kb_layout`, loading those layouts onto the session keyboard too.

Apply the choice as a per-device `hyprctl keyword device[<name>]:kb_layout`
instead — the runtime twin of the declarative `keyboard.devices` blocks —
so it isolates that one keyboard and never touches the built-in board.
Keep the candidate pool out of `input.kb_layout` (session keyboard carries
only `keyboard.layout`); the pool is for external boards, applied per-device.

Also put `nomarchy-keyboard-watch` on PATH when enabled (it was store-path
only via exec-once, so undiscoverable) for debugging.

Found on the Latitude 5410 hardware sweep; picker itself verified working.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-06-18 17:47:19 +01:00
parent 82659566ac
commit b4fe52261b
3 changed files with 45 additions and 28 deletions

View File

@@ -372,15 +372,20 @@ how to override it. Items marked ✓ are shipped.
watch` daemon runs (exec-once): it polls `hyprctl devices`, and when a
keyboard connects *after* login that isn't in `keyboard.devices` and
hasn't been chosen before, it pops a rofi layout picker, applies the
choice with `hyprctl switchxkblayout` (an index into the candidate set,
which `input.kb_layout` carries), and remembers it per-device in
`~/.local/state/nomarchy/keyboard-layouts` — re-applied silently on later
reconnects. The boot-time set (incl. the built-in keyboard) is never
prompted. The runtime-remember complement to the declarative
`keyboard.devices`; a stateful runtime piece by design. **Pending an
on-hardware test** (hotplug isn't verifiable in CI). Remaining (bonus):
offer to write a choice into `keyboard.devices` so it graduates to the
reproducible config.
choice as a **per-device** `hyprctl keyword device[<name>]:kb_layout` (the
runtime twin of the declarative `device{}` blocks — so it isolates that
one keyboard and never touches the built-in board), and remembers it
per-device in `~/.local/state/nomarchy/keyboard-layouts` — re-applied
silently on later reconnects. The boot-time set (incl. the built-in
keyboard) is never prompted. The runtime-remember complement to the
declarative `keyboard.devices`; a stateful runtime piece by design.
**Picker verified on hardware (2026-06-18)**; the first cut applied the
choice with `switchxkblayout` (a global layout-index flip) and merged the
candidate pool into `input.kb_layout`, so a selection leaked onto the
laptop keyboard and stuck after unplug — fixed by the per-device keyword +
keeping the pool out of the session layout. Remaining (bonus): offer to
write a choice into `keyboard.devices` so it graduates to the reproducible
config; **re-verify the per-device isolation on hardware**.
- Remaining: a multi-layout cycle bind (`hyprctl switchxkblayout` / xkb
`grp:` options) for switching layouts on one keyboard; add the
`hyprland/language` module to the summer whole-swap themes for parity