I built PowerToys for Linux in Python. Here's how key remapping works on Wayland
Описание и применение
Knobu реализует универсальный ключевой маппер для Linux, работая как на Wayland, так и на X11, захватывая физические клавиатуры и отправляя события виртуальной клавиатуры.
Задача
Wayland does not allow applications to intercept key events, preventing a universal key remapper.
Результат
Knobu provides a single key‑remapping daemon that works across KDE, GNOME, Wayland, and X11 by operating below the compositor.
Рабочий процесс
- Create a virtual keyboard with python‑evdev's UInput
- Grab each physical keyboard device
- Read key events, apply remap rules, write transformed events to the virtual keyboard
Доказательства
On X11, remapping tools could ask the X server to intercept keys. On Wayland, that's deliberately impossible: an app only sees keys while its own window is focused.
Linux exposes every input device as /dev/input/event* (evdev). A process can grab a device, which means nobody else (including the compositor) receives its events.
Knobu waits until dev.active_keys() is empty before grabbing.
- Дата записи: 2026-11-03T18:14:15.911Z