Skip to content

Instantly share code, notes, and snippets.

@vtvh
Created June 28, 2026 07:19
Show Gist options
  • Select an option

  • Save vtvh/15ae0e8fbad1e2c2c261075d10e14687 to your computer and use it in GitHub Desktop.

Select an option

Save vtvh/15ae0e8fbad1e2c2c261075d10e14687 to your computer and use it in GitHub Desktop.
Help me to setup keyboard in linux. prefer a universal way despite the fuzz about wayland/x11. capslock as ctrl keep the left ctrl as-is right control as capslock

Capslock as Ctrl

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:

Step 1: Install keyd

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
    

Step 2: Configure the Remaps

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).

Step 3: Start and Enable the Daemon

Run the following commands to tell systemd to start the utility now and automatically launch it on boot:

sudo systemctl enable --now keyd

Checking Your Changes

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
@vtvh

vtvh commented Jun 28, 2026

Copy link
Copy Markdown
Author
  1. install from source and make
  2. FUTURE: remap us>colemak inside keyd
  3. use this:
[ids]

*

[main]

shift = oneshot(shift)
meta = oneshot(meta)
control = oneshot(control)

leftalt = oneshot(alt)
rightalt = oneshot(altgr)

capslock = overload(control, esc)
insert = S-insert
# conflict with colkemak: rightcontrol = capslock

@vtvh

vtvh commented Jun 28, 2026

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment