To bypass the entire Wayland vs. X11 headache completely, you need to step down to the kernel level. The most reliable, lightweight, and modern universal tool for this is keyd. Because keyd hooks directly into evdev (the Linux kernel input subsystem), your keybindings will work flawlessly across GNOME, KDE, Hyprland, Sway, the virtual TTY console, and any display server. Here is how to set it up to achieve exactly what you want:
Install it using your distribution's package manager:
- Ubuntu / Debian / Linux Mint:
sudo apt install keyd
- Arch Linux:
sudo pacman -S keyd
- Fedora:
sudo dnf install keyd
Create the configuration directory and file:
sudo mkdir -p /etc/keyd
sudo nano /etc/keyd/default.conf
Paste the following configuration inside the file:
[ids]
*
[main]
# Remap Caps Lock to Control
capslock = control
# Remap Right Control to Caps Lock
rightcontrol = capslock
# (Note: Left Control is omitted here, so it safely keeps its default as-is)
Save and exit (Ctrl+O, Enter, then Ctrl+X).
Run the following commands to tell systemd to start the utility now and automatically launch it on boot:
sudo systemctl enable --now keyd
The layout applies instantly.
- Tapping Caps Lock will now behave exactly like pressing Left Ctrl.
- Tapping Right Ctrl will now toggle your Caps Lock status.
- Left Ctrl stays completely untouched. If you ever make changes to /etc/keyd/default.conf in the future, you can instantly apply them without restarting by running:
sudo keyd reload