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

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

说明与用途

Knobu 实现了一个通用键盘重映射工具,兼容 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