Per-keyboard layout switcher for Niri compositor. Automatically switches keyboard layouts based on which physical keyboard you're typing on.
kunai monitors your keyboards and switches to a configured layout when you start typing on a specific keyboard. Perfect for multi-keyboard setups where different keyboards use different layouts (e.g., QWERTY laptop keyboard + Colemak mechanical keyboard).
- Linux with Niri compositor
- Rust toolchain (cargo)
- Access to
/dev/input/event*devices
./install.shThis will:
- Build the release binary
- Install to
/usr/local/bin/kunai - Set up udev rules for keyboard access (no reboot/logout required)
- List available keyboards:
kunai list- Run interactive setup to map keyboards to layouts:
kunai setup- Test the configuration (optional):
kunai daemon --dry-run- Add to Niri startup config (
~/.config/niri/config.kdl):
spawn-at-startup = "kunai" "daemon"Or run manually:
kunai daemonkunai list- List detected keyboards with IDskunai setup- Interactive configuration for keyboard-to-layout mappingkunai daemon- Run as background daemonkunai daemon --dry-run- Test mode, prints switches without applyingkunai test- Show which keyboard generates events
Configuration is stored in ~/.config/kunai/config.toml and maps keyboard vendor/product IDs to Niri layout indices.