Files
RedBear-OS/local/recipes/system/redbear-keymapd
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00
..

redbear-keymapd

Keyboard layout daemon — scancode-to-character translation with builtin keymaps, JSON keymap loading, and XKB integration.

Status: FEATURE-INCOMPLETE Category: system Build: ./local/scripts/build-redbear.sh redbear-full (via redbear-full.toml)

Purpose

Manages keyboard layouts and performs scancode-to-character translation for Red Bear OS. Supports six builtin keymaps (US, GB, dvorak, azerty, bepo, it), runtime loading from JSON keymap files, and optional XKB-backed keymap loading via libxkbcommon. Compositors and terminal emulators query this daemon to translate raw scancodes into Unicode characters.

Interface

  • Scheme: keymap — path convention: keymap:/active, keymap:/list, keymap:/keymap/<name>, keymap:/set/<name>
  • Init service: /usr/lib/init.d/13_redbear-keymapd.service
  • Configuration: Environment variables: KEYMAP_DIR (default /etc/keymaps), XKB_CONFIG_ROOT, XKB_DEFAULT_LAYOUT (default us), XKB_DEFAULT_VARIANT

Architecture

File Purpose
src/main.rs Daemon entry — loads builtins → JSON keymaps → XKB keymap, registers scheme:keymap
src/scheme.rs KeymapScheme — implements SchemeSync with openat/read/write/fstat/fpath
src/keymap.rs Keymap type + BuiltinKeymaps — scancode lookup tables for 6 keyboard layouts
src/xkb.rs XKB integration — loads keymaps via libxkbcommon /usr/share/X11/xkb
src/lib.rs Library crate keymapd — shared types for potential consumers

Dependencies: redox-scheme, redox_syscall, serde, serde_json (path deps + crates.io).

Consumers

  • evdevd — translates scancodes using keymap:/keymap/<name> or keymap:/active
  • Wayland compositors (redbear-compositor, kwin) — query layout info for keyboard handling
  • Terminal emulators (konsole, etc.) — key translation for text input

Status Notes

  • Compiles against the current relibc/kernel forks.
  • Six builtin keymaps are embedded and load immediately at startup.
  • JSON keymap loading from KEYMAP_DIR is implemented — expects JSON files with per-scancode entries, compose tables, and dead-key maps.
  • XKB integration is wired but depends on libxkbcommon data files being staged at /usr/share/X11/xkb — this path was recently re-enabled in the build.
  • Runtime keymap switching works via writing a keymap name to keymap:/active.
  • No runtime validation on bare metal or QEMU for XKB path. Builtin keymaps are validated at compile time via unit tests in the keymap module.