From 8759104cc102f10043dab7eb86ac09002cbf2130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?La=C3=A9rcio=20de=20Sousa?= Date: Thu, 12 Nov 2026 23:31:01 -0300 Subject: [PATCH] feat(capslock)!: Caps Lock as Esc through XKB, without keyd caps:escape_shifted_capslock does the remap on its own: Caps Lock is Esc and Shift+Caps Lock is Caps Lock. The user block in ~/.config/hypr/input.lua now sets it next to compose:menu, and the feature is user-only. - Remove playbooks/system/capslock.yml, keyd-default.conf and the keyd_config_dest variable. - Holding Caps Lock no longer acts as Ctrl. A machine that installed keyd keeps it, and it still remaps Caps Lock; take it off by hand: systemctl disable --now keyd, remove /etc/keyd/default.conf and uninstall keyd. Co-Authored-By: Claude Opus 5.5 --- docs/features.md | 2 +- docs/multi-user.md | 2 +- features.yml | 6 +- group_vars/all/main.yml | 5 +- playbooks/files/keyd-default.conf | 38 ------------- playbooks/system/capslock.yml | 95 ------------------------------- playbooks/user/capslock.yml | 20 +++---- system.yml | 3 - user.yml | 2 +- 9 files changed, 18 insertions(+), 155 deletions(-) delete mode 100644 playbooks/files/keyd-default.conf delete mode 100644 playbooks/system/capslock.yml diff --git a/docs/features.md b/docs/features.md index 1069e46..51dfcc1 100644 --- a/docs/features.md +++ b/docs/features.md @@ -42,7 +42,7 @@ always applied. | Screen scale + text size | `text-size` | modifies the monitor scale (100%, the login screen's too), GDK_SCALE, the shell/terminal text size and the GNOME font sizes | system, user | on | no | | Night light at sunset/sunrise | `nightlight-solar` | adds a timer that follows the real sunset/sunrise with hyprsunset | user | on | yes | | Firefox follows the Omarchy theme | `omafox` | adds the Omafox add-on to Firefox's policies, its native messaging host and a theme-set hook; the add-on stays in the profile when reverted | system, user | on | yes | -| Caps Lock via keyd | `capslock` | adds keyd (tap Esc, hold Ctrl, Shift+Caps Lock = Caps Lock); modifies Compose (Menu key instead of Shift+Caps Lock) | system, user | on | yes | +| Caps Lock as Esc | `capslock` | modifies the keyboard options (Caps Lock = Esc, Shift+Caps Lock = Caps Lock, Compose on the Menu key instead of Shift+Caps Lock) | user | on | yes | ## Themes diff --git a/docs/multi-user.md b/docs/multi-user.md index 7c4c48d..3a01240 100644 --- a/docs/multi-user.md +++ b/docs/multi-user.md @@ -165,7 +165,7 @@ notified only when one actually fails (log: | What | Why | Where | |---|---|---| -| Packages, `/etc/locale.conf`, keyd, the printer queue, Plymouth, Limine | They belong to the machine | system phase | +| Packages, `/etc/locale.conf`, the printer queue, Plymouth, Limine | They belong to the machine | system phase | | Homebrew | One prefix with one owner (`homebrew_owner`); others can run what it installed | `system/homebrew.yml` | | The greeter's colors | Style › Unlock recolors the login screen for everyone, so only administrators see it in the menu | omarchy-multiuser | | The browsers' theme color policy | Omarchy writes it to `/etc` on every theme change, and its sudoers rule is `%wheel`. The last administrator to change theme wins; for anyone else omarchy-multiuser's polkit rule refuses it without a prompt, so their theme changes leave it alone. | Omarchy, omarchy-multiuser | diff --git a/features.yml b/features.yml index 5a4310d..3658d11 100644 --- a/features.yml +++ b/features.yml @@ -177,9 +177,9 @@ features: - id: capslock group: desktop - title: Caps Lock via keyd - effect: adds keyd (tap Esc, hold Ctrl, Shift+Caps Lock = Caps Lock); modifies Compose (Menu key instead of Shift+Caps Lock) - phases: [system, user] + title: Caps Lock as Esc + effect: modifies the keyboard options (Caps Lock = Esc, Shift+Caps Lock = Caps Lock, Compose on the Menu key instead of Shift+Caps Lock) + phases: [user] default: true revert: true diff --git a/group_vars/all/main.yml b/group_vars/all/main.yml index f4d5f33..4075594 100644 --- a/group_vars/all/main.yml +++ b/group_vars/all/main.yml @@ -941,12 +941,11 @@ omarchy_gnome_font_sizes: # point from the 12pt Omarchy leaves behind. omarchy_system_ui_font_pt: 13 -# Caps Lock via keyd (playbooks/{system,user}/capslock.yml). Key that takes over Compose -# from Caps Lock — must not be a hardware modifier (Ctrl/Alt/Win keep +# Caps Lock as Esc (playbooks/user/capslock.yml). Key that takes over Compose +# from Shift+Caps Lock — must not be a hardware modifier (Ctrl/Alt/Win keep # acting as modifiers even after their symbol changes; "menu" doesn't have # that problem and is the natural Compose key already). capslock_compose_key: menu -keyd_config_dest: /etc/keyd/default.conf # Night light synced to real sunrise/sunset (playbooks/{system,user}/desktop.yml). # hyprsunset only supports fixed HH:MM profile times, so a daily timer diff --git a/playbooks/files/keyd-default.conf b/playbooks/files/keyd-default.conf deleted file mode 100644 index ed11141..0000000 --- a/playbooks/files/keyd-default.conf +++ /dev/null @@ -1,38 +0,0 @@ -# Caps Lock remapped at the evdev level: tap = Esc, hold = Ctrl, -# Shift+Caps Lock = literal Caps Lock (toggles the LED normally). Works -# the same in TTY and Wayland, unlike setxkbmap/GNOME "Input Sources". -# -# PREREQUISITE: Omarchy's Compose key must not be on Caps Lock -# (playbooks/user/capslock.yml moves it to Menu first) — while Compose is on -# Caps Lock, nothing here can produce a real Caps Lock toggle. -# -# overload(control, esc): holding the key activates the "control" layer; -# a lone tap (no other key in between) emits Esc. -# -# [shift]'s "capslock = capslock" overrides Caps Lock while Shift is -# held, emitting a literal Caps Lock instead of the overload. -# -# Key order matters for that override: overload() commits to "hold" -# (control) as soon as any other key is pressed while Caps Lock is down — -# including Shift. So Shift-then-CapsLock emits a literal Caps Lock, but -# CapsLock-then-Shift emits Ctrl+Shift instead. This is a structural -# limitation of keyd's overload(), not a config bug. -# -# Managed by playbooks/user/capslock.yml — manual edits are overwritten on -# the next run. -# -# NOTE: keyd only recognizes '#' as a comment marker, not ';'. A stray -# ';' breaks the parser silently (keyd then ignores every keyboard, -# including the built-in one, with no visible error outside -# `journalctl -u keyd`). -# -# Panic sequence if a bad config locks up the keyboard: -# backspace+esc+enter (kills keyd). -[ids] -* - -[main] -capslock = overload(control, esc) - -[shift] -capslock = capslock diff --git a/playbooks/system/capslock.yml b/playbooks/system/capslock.yml deleted file mode 100644 index 2919e16..0000000 --- a/playbooks/system/capslock.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -# Caps Lock remapped at the evdev level via keyd: tap = Esc, hold = Ctrl, -# Shift+Caps Lock = literal Caps Lock. Works the same in TTY and -# Wayland, unlike setxkbmap/GNOME "Input Sources". -# -# Omarchy 4.5 makes Shift+Caps Lock the Compose key -# (`omarchy:shift_caps_compose`, defined in /etc/xkb). keyd's -# Shift+CapsLock = CapsLock reaches XKB as exactly that chord, so it would -# type Compose instead of toggling Caps Lock — the XKB layer acts on the -# keycode regardless of which device sent it. user/capslock.yml therefore -# moves Compose to another key. It must be a non-hardware-modifier key: Ctrl/Alt/Win stay wired -# into XKB's modifier_map by keycode regardless of their assigned -# symbol, so they'd keep acting as both the modifier and Compose at -# once. The Menu key works cleanly and is already the natural Compose -# key on keyboards that have one. -# -# See playbooks/files/keyd-default.conf for the full remap config, -# including the caveat that Shift+CapsLock only works with Shift -# pressed before Caps Lock. -# -# Panic sequence if a bad config locks up the keyboard: -# backspace+esc+enter (kills keyd). -# -# keyd is machine-wide and applies to every user's keyboard, but Compose -# lives in each user's ~/.config/hypr/input.lua: user/capslock.yml moves it -# off Caps Lock, and every user needs it (`just user`), or keyd swallows -# their Compose key. -# -# Usage: just apply capslock -- name: Caps Lock via keyd (tap=Esc / hold=Ctrl / Shift+CapsLock=CapsLock) - hosts: localhost - connection: local - gather_facts: false - tags: [capslock] - - vars: - feature_on: "{{ features['capslock'] | default(true) }}" - - tasks: - - name: Caps Lock via keyd - become: true - when: feature_on | bool - block: - - name: Install keyd via pacman - community.general.pacman: - name: keyd - state: present - - - name: Ensure /etc/keyd exists - ansible.builtin.file: - path: "{{ keyd_config_dest | dirname }}" - state: directory - mode: "0755" - - - name: Install the Caps Lock config - ansible.builtin.copy: - src: keyd-default.conf - dest: "{{ keyd_config_dest }}" - mode: "0644" - notify: restart keyd - - - name: Enable and start keyd - ansible.builtin.systemd: - name: keyd - enabled: true - state: started - - - name: Caps Lock back to Omarchy's - become: true - when: not feature_on | bool - block: - - name: Stop and disable keyd - ansible.builtin.systemd: - name: keyd - enabled: false - state: stopped - failed_when: false - - - name: Remove the Caps Lock config and keyd - ansible.builtin.file: - path: "{{ keyd_config_dest }}" - state: absent - - - name: Uninstall keyd - community.general.pacman: - name: keyd - state: absent - - handlers: - - name: restart keyd - ansible.builtin.systemd: - name: keyd - state: restarted - become: true - listen: restart keyd diff --git a/playbooks/user/capslock.yml b/playbooks/user/capslock.yml index 96a0112..6b7dc55 100644 --- a/playbooks/user/capslock.yml +++ b/playbooks/user/capslock.yml @@ -1,14 +1,14 @@ --- -# Caps Lock, per user: Compose moves from Shift+Caps Lock (Omarchy 4.5's -# omarchy:shift_caps_compose) to capslock_compose_key in -# ~/.config/hypr/input.lua, so the machine-wide keyd remap -# (system/capslock.yml, which explains it) can produce a real Caps Lock. -# Every user needs this; turning the feature off removes the block (and, -# in the system phase, keyd). The layout-switch option Omarchy adds for -# non-Latin layouts (grp:alts_toggle) is kept. +# Caps Lock = Esc, Shift+Caps Lock = Caps Lock, with XKB's own +# caps:escape_shifted_capslock in ~/.config/hypr/input.lua — no daemon. +# Omarchy's kb_options (omarchy:shift_caps_compose) put Compose on +# Shift+Caps Lock, so the block replaces them and moves Compose to +# capslock_compose_key. The layout-switch option Omarchy adds for +# non-Latin layouts (grp:alts_toggle) is kept. Turning the feature off +# removes the block, giving Omarchy's options back. # # Usage: just apply capslock -- name: Caps Lock via keyd (tap=Esc / hold=Ctrl / Shift+CapsLock=CapsLock) (user) +- name: Caps Lock = Esc, Shift+Caps Lock = Caps Lock (user) hosts: localhost connection: local gather_facts: false @@ -18,14 +18,14 @@ feature_on: "{{ features['capslock'] | default(true) }}" tasks: - - name: "{{ 'Move Compose off Caps Lock, onto ' ~ capslock_compose_key if feature_on | bool else 'Give Compose back to Omarchy (Shift+Caps Lock)' }}" + - name: "{{ 'Caps Lock as Esc, Compose on ' ~ capslock_compose_key if feature_on | bool else 'Give Caps Lock and Compose back to Omarchy' }}" ansible.builtin.include_tasks: tasks/hypr-user-block.yml vars: hypr_file: input.lua hypr_marker: "playbooks/user/capslock.yml — Compose on {{ capslock_compose_key }}" hypr_state: "{{ 'present' if feature_on | bool else 'absent' }}" hypr_block: | - local capslock_kb_options = "compose:{{ capslock_compose_key }}" + local capslock_kb_options = "caps:escape_shifted_capslock,compose:{{ capslock_compose_key }}" local omarchy_kb_options = hl.get_config("input.kb_options") if type(omarchy_kb_options) == "string" and omarchy_kb_options:find("grp:alts_toggle", 1, true) then capslock_kb_options = capslock_kb_options .. ",grp:alts_toggle" diff --git a/system.yml b/system.yml index 1a1fb6b..6a47ced 100644 --- a/system.yml +++ b/system.yml @@ -78,9 +78,6 @@ - name: Login screen scale ansible.builtin.import_playbook: playbooks/system/desktop.yml -- name: Caps Lock via keyd - ansible.builtin.import_playbook: playbooks/system/capslock.yml - - name: openssh rebuilt with askpass touch notifications ansible.builtin.import_playbook: playbooks/system/openssh-askpass.yml diff --git a/user.yml b/user.yml index b707255..b989b3b 100644 --- a/user.yml +++ b/user.yml @@ -70,7 +70,7 @@ - name: Column resize keys, vertical workspace switching, scale and text size, night light at sunset ansible.builtin.import_playbook: playbooks/user/desktop.yml -- name: Compose off Caps Lock (for keyd) +- name: Caps Lock = Esc, Shift+Caps Lock = Caps Lock ansible.builtin.import_playbook: playbooks/user/capslock.yml - name: "Themes: Omadwaita, Omaraptor, Osaka Jade, Piedmont Gold"