Skip to content

Send clipboard shortcuts using physical XKB keys - #9130

Closed
yashranaway wants to merge 4 commits into
omacom:quattrofrom
yashranaway:fix/clipboard-layout-independent-keys
Closed

yashranaway wants to merge 4 commits into
omacom:quattrofrom
yashranaway:fix/clipboard-layout-independent-keys

Conversation

@yashranaway

@yashranaway yashranaway commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Copy, paste, cut, and select all should keep working when the active keyboard layout has no Latin letters. This sends the physical keys while keeping the current terminal shortcuts. Fixes #8960.

<<<< AI wording below >>>>

Problem

Hyprland resolves synthetic key names such as C against the active layout. On non-Latin layouts, send_key_state can report key not found. The code: form expects XKB keycodes, which differ from Linux evdev codes by eight.

Fix

Use XKB keycodes 38, 54, 55, and 53 for A, C, V, and X. Keep the current Ctrl+Shift+C/V shortcuts for terminals and Ctrl+C/V elsewhere.

Verification

The default Hyprland config and binding-conflict tests pass in a container with Lua 5.4. A Lua test exercises the callback for each shortcut and checks the key, modifiers, and down/up events. Shell syntax and git diff --check pass. No live non-Latin keyboard session was available.

@bwynnyck

bwynnyck commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

This is very much needed. I hope the next PR review wave comes soon. For now the same can be achieved by pasting

hl.unbind("SUPER + C")
hl.unbind("SUPER + V")
hl.unbind("SUPER + X")
o.bind("SUPER + C", "Universal copy", universal_physical_shortcut("CTRL", "54", "CTRL", "118"))
o.bind("SUPER + V", "Universal paste", universal_physical_shortcut("CTRL", "55", "SHIFT", "118"))
o.bind("SUPER + X", "Universal cut", send_physical_shortcut_once("CTRL", "53"))

Into ~/.config/hypr/bindings.lua on a live stable system.

@yashranaway yashranaway changed the title Send clipboard shortcuts by keycode Send clipboard shortcuts using physical XKB keys Sep 24, 2026
@yashranaway

Copy link
Copy Markdown
Contributor Author

Your XKB keycodes were right; I've switched to 54/55/53, preserved the current terminal shortcuts, and covered the callbacks in a Lua test.

@WokoFlipper

Copy link
Copy Markdown

Measurement from a live non-Latin session, separating this from #13007 (per @linyiru request in #12557).

Environment: Hyprland 0.56.2, layouts us,ru,us, Omarchy 4.0.4-1. Our ru pack already runs the equivalent of this PR live (code:54/55 for copy/paste under a Cyrillic layout) — works, because the primary is QWERTY.

The separator is a non-QWERTY primary. Via xkbcli (same XKB data Hyprland resolves against):

| letter | QWERTY keycode (this PR) | us-dvorak keycode (#13007) | letter sitting at this PRs keycode on dvorak |
| C | 54 | 31 | j |
| V | 55 | 60 | k |
| X | 53 | 56 | q |
| A | 38 | 38 | a (coincides) |

So on a Dvorak primary this PR sends CTRL+J / CTRL+K / CTRL+Q (quit!) for copy/paste/cut, while #13007 resolves 31/60/56 correctly. Hardcoded QWERTY positions are only safe when the primary is QWERTY; the primary-layout resolution covers that case plus Dvorak/AZERTY.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed against quattro by Claude Opus 5.5. The bug is real — a named key like C cannot be resolved by send_key_state while a non-Latin group is active — but hardcoding QWERTY keycodes trades it for a worse one on non-QWERTY Latin layouts, so this is not the fix I would bring forward.

send_key_state with code:N sends a physical key, and the application then reads that key through the user's own layout. Checked with xkbcli how-to-type against the stock keymaps:

  • French AZERTY: keycode 38 is q, so SUPER+A sends Ctrl+Q and quits the focused browser or editor instead of selecting all.
  • US Dvorak: keycodes 54/55/53 are j/k/q, so copy becomes Ctrl+J, paste Ctrl+K, and cut Ctrl+Q — quit again. @WokoFlipper measured the same above.

Today both layouts work, because the named key resolves through the active layout. The Lua test cannot catch this, since it stubs send_key_state and only checks the strings passed to it.

#13007 fixes the same bug by resolving each letter against the configured primary layout with xkbcli, which keeps the non-Latin case working without assuming QWERTY, so it is the competing fix I am recommending to the maintainer over this one. It is larger and starts a subprocess the first time each shortcut is used, and it is being reviewed as its own item; choosing between the two is the maintainer's call. The branch also conflicts with current quattro on the last line of clipboard.lua (the clipboard manager binding now opens { panel = "omarchy.clipboard" }).

Nothing was run on a worker, since verifying a fix that is not the one being recommended would test nothing anyone is about to merge. The second opinion (Codex Medium) did not review this: it answered a ping, but its daily review allowance was already spent, so this rests on one model's reading. Waiting on the maintainer.

@yashranaway

Copy link
Copy Markdown
Contributor Author

Confirmed with compiled XKB maps: these physical keycodes send Ctrl+Q for AZERTY select-all and Dvorak cut. I'm closing this hardcoded approach; #13007 resolves shortcuts against the configured layout.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Universal clipboard shortcuts (Super+C/V/X) fail with 'send_key_state: key not found' on non-Latin keyboard layouts (e.g. Arabic)

4 participants