feat(keyboard): interactive new-keyboard layout prompt + persist

The runtime-remember complement to nomarchy.keyboard.devices. Set
nomarchy.keyboard.layouts (candidate layouts) and a nomarchy-keyboard-watch
daemon runs (exec-once): it polls hyprctl devices, and when a keyboard
connects after login that isn't declared and hasn't been chosen before, it
pops a rofi layout picker, applies the choice via hyprctl switchxkblayout (an
index into the candidate set carried by input.kb_layout), and remembers it
per-device in ~/.local/state -- re-applied silently on later reconnects. The
boot-time set (incl. the built-in keyboard) is never prompted.

Pure bash + jq/hyprctl/rofi (all in the session PATH); state lives outside
the flake (a stateful runtime piece by design). Eval + bash-syntax verified;
the hotplug behaviour needs an on-hardware test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-06-15 17:43:59 +01:00
parent 69f959365e
commit 71f37bfc30
5 changed files with 92 additions and 13 deletions

View File

@@ -293,17 +293,20 @@ how to override it. Items marked ✓ are shipped.
declarative way). A Waybar `hyprland/language` indicator shows the active
layout, gated on more than one layout being in play (comma in the session
layout, or any per-device override) so single-layout bars stay clean.
- **Interactive new-keyboard prompt (runtime + persist):** a small daemon
listening to Hyprland's socket for keyboard hotplug — when an *unknown*
keyboard connects, pop a rofi layout picker, apply the choice
(`hyprctl switchxkblayout` among a configured candidate set, or reload the
device config), and persist it per-device to a state file so it re-applies
automatically on every later reconnect. The runtime-remember complement to
the declarative `nomarchy.keyboard.devices` above (set it once, on the fly,
no config editing). Nice bridge: offer to also write the choice into
`nomarchy.keyboard.devices` so it graduates into the reproducible config.
Note: a stateful runtime piece (like the wallpaper) — it sits outside the
pure-declarative model by design.
- **Interactive new-keyboard prompt (runtime + persist):** set
`nomarchy.keyboard.layouts` (candidate layouts) and a `nomarchy-keyboard-
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.
- 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