Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I built PowerToys for Linux in Python. Here's how key remapping works on Wayland

Description and use

Knobu implements a universal key remapper for Linux that works on both Wayland and X11 by grabbing physical keyboards and emitting events from a virtual keyboard.

Problem

Wayland does not allow applications to intercept key events, preventing a universal key remapper.

Outcome

Knobu provides a single key‑remapping daemon that works across KDE, GNOME, Wayland, and X11 by operating below the compositor.

Workflow

  • 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

Evidence

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.

Source

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.

Source

Knobu waits until dev.active_keys() is empty before grabbing.

Source

  • Record date: 2026-11-03T18:14:15.911Z