Expand description
Linux keystroke capture.
Reads key events from every keyboard under /dev/input via evdev
and translates them — honoring the keyboard layout and modifiers via
xkbcommon — into Key values for the keystroke buffer.
The trigger chord itself (Super+Ctrl+Shift+Alt+letter) is not
delivered here — Hyprland intercepts it (via the inline keybind set
up by hotkey) and signals the daemon over SIGUSR1. Capture only
suppresses the would-be Key::Reset that the chord’s letter
press would otherwise emit, so the buffer survives the chord and
the trigger has a word to fix.
One OS thread per keyboard device runs for the life of the process;
start returns the channel they feed.
Layout note: the keymap is the system / XKB_DEFAULT_* default. A
layout configured only in the compositor (e.g. hyprland.conf) is
not yet read — that is M5 polish.
Structs§
- Reset
KeyConfig - User-configurable view of which “control” keys reset the
per-window buffer. The daemon passes the current settings via
set_reset_keysat startup and on every config reload;classifyreads it under aRwLock::read(essentially free) to decide whether a given key is aKey::Resetor just ignored. Defaults match the safest behavior — every context-changing key resets except for Tab and Escape, which rarely change typed text and would otherwise drop the buffer for no gain.
Enums§
- Capture
Error - An error starting keystroke capture.
Functions§
- caret_
suspect_ flag - Shared flag set by the mouse-listener threads whenever the user
clicks a mouse button, and cleared by the daemon after the next
fix-word emit or buffer reset. When
true, the daemon’s word-fix path widens its nearby-word scan to the entire buffer — the buffer’s caret tracking can’t follow a mouse click, but the buffer’s text is still accurate, so scanning all of it for a typo is the best we can do without OS-level cursor snooping. Returned as anArcso the daemon can both read and reset it. - set_
reset_ keys - Replace the daemon-wide reset-key config. Cheap (one
RwLockwrite); call at startup and on every config reload. - start
- Start capturing keystrokes from every keyboard under
/dev/input. - wait_
mods_ clear - Block up to
timeoutfor every chord modifier (Ctrl/Shift/Alt/ Super) to be released across every keyboard device the daemon is watching. Returnstrueif everything cleared in time,falseon timeout.