omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

SUPER+C/V/X universal clipboard shortcuts fail with "send_key_state: key not found" when a non-Latin keyboard layout is active

Open rsoutar opened this issue 3 months ago • 11 comments

System details

Intel Core i5-8265U (ThinkPad X390, iGPU), Omarchy omarchy-dev 4.0.0.r1772.gf32ebbd-1, Hyprland 0.56.2, kernel 7.1.8-arch1-3

What's wrong?

With a multi-layout keyboard (e.g. kb_layout = "us,th"), pressing SUPER+C (also SUPER+V / SUPER+X) while the non-Latin layout is active pops up Runtime error in lua: send_key_state: key not found and nothing is copied. It works fine in the English layout.

Steps to reproduce

  1. ~/.config/hypr/input.lua: kb_layout = "us,th", kb_options = "grp:caps_toggle"
  2. Switch to Thai (CapsLock), select text in any app, press SUPER+C
  3. Error popup appears; clipboard unchanged. Switch back to English → works.

Notable: once SUPER+C succeeds once in English after a Hyprland reload, it starts working in Thai too until the next reload (keycode cache).

Root cause (verified against Hyprland v0.56.2 source)

  • default/hypr/bindings/clipboard.lua calls hl.dsp.send_key_state({ mods = "CTRL", key = "C", ... }).
  • Hyprland's resolveKeycode (src/config/lua/bindings/LuaBindingsDispatchers.cpp) maps key name "C" → keysym → keycode by scanning the keymap, but applies the currently active layout group (xkb_state_update_mask(..., KB->m_modifiersState.group)) before xkb_state_key_get_one_sym(). The Thai group has no Latin keysyms, so "C" is never found and the dispatcher raises send_key_state: key not found as a Lua runtime error.
  • The keycode cache key (keyboard pointer + key name) doesn't include the group — explaining the "works after first success in English" behavior.
  • Still present on Hyprland main (src/keybinds/Resolver.cpp uses KB->m_xkbSymState, which tracks the active group).

Possible fixes

  • Omarchy: pass evdev keycodes instead of names in clipboard.lua — key = "code:46" (C), "code:47" (V), "code:45" (X), "code:110" (Insert). resolveKeycode bypasses keysym resolution for code:NN, so the shortcuts work in any layout — mirroring a physical Ctrl+C press, which toolkits (GTK/Qt) match across layout groups.
  • Hyprland (upstream): resolveKeycode should search all layout groups (or fall back to group 0) instead of only the active one.

rsoutar avatar Aug 18 '26 08:08 rsoutar

I can confirm the issue with us,ru layout. Pasting by SUPER+V to any chromium page with RU active layout shows the error: Image

Pasting with EN layout works perfectly fine.

My AI agent came up with a solution to the issue, which is works for me:

Image

Riddlerrr avatar Aug 18 '26 09:08 Riddlerrr

Hit the same bug on us,ua and opened #7375 with exactly this fix — injecting the letters by keycode in clipboard.lua.

Great root-cause analysis. One correction on the keycode scheme though: code: here takes XKB keycodes (evdev + 8), not raw evdev codes. In resolveKeycode, the keysym path returns the raw xkb keycode (kc from the keymap scan) into the same downstream injection as the code:NN early-return — so the two must be in the same scheme, and the keysym path demonstrably works with xkb keycodes. That makes it code:54/code:55/code:53 for C/V/X (same scheme binds use).

Verified on us,ua (Omarchy 4.0.0, Hyprland 0.56.2): with the keycode injection Super+C/V/X work on both layouts, browsers and terminals. It also sidesteps the group-less m_keyToCodeCache poisoning you spotted, since code:NN never touches the cache.

nazarenkodima avatar Aug 18 '26 11:08 nazarenkodima

Still reproduces on released Omarchy 4.0.1-1 with Hyprland 0.56.2-1 (us,ru, grp:win_space_toggle) — the issue was filed against 4.0.0-dev, so confirming it survived into the release.

Can also confirm the keycode scheme correction: code:54/code:55/code:53 work, applied as a local override in ~/.config/hypr/bindings.lua (mirroring the stock terminal-detection logic). Worth noting clipboard.lua is the only place in the defaults that passes letter names to send_key_state — tiling.lua and utilities.lua already use code:NN — so #7375 makes it consistent with the rest of the config.

nikbrain avatar Aug 28 '26 16:08 nikbrain

I checked this against current quattro and the open fix in #13007.

Still present on quattro. default/hypr/bindings/clipboard.lua still passes the letter names A, C, V and X to hl.dsp.send_key_state, in terminals (Ctrl+Shift+C/V) as well as other windows. Hyprland 0.56.2 resolves a name against the active layout group only, and caches a successful lookup without the group, which matches both the error under a Thai, Russian, Ukrainian or Bulgarian group and the "works after one success in English" behaviour you describe.

Fix in review: #13007. It resolves each letter against the configured primary layout with xkbcli how-to-type and sends the resulting code:N, which Hyprland takes without the active-group lookup. For kb_layout = "us,th" that gives code:54/55/53 for C/V/X, the XKB keycodes the comments here arrived at, and it also keeps Dvorak and AZERTY primaries on the right letters, which hardcoded QWERTY codes in the earlier #7375 and #9130 did not. It was run on an Omarchy worker earlier with us,ru: quattro failed with key not found and the fix delivered the shortcuts. It does not handle a keymap set with kb_file or per-device layout overrides; those fall back to today's behaviour. Two later reports of this same case, #8960 and #12570, point here or at #13007. #7027 covers the same error but its original single-layout French trigger is not established, so it is tracked separately.

#13007 does not yet say it closes this issue. I tried to link it, and the bot refused because #13007 has been pushed to since it was last classified. It needs to be reviewed again at its new head first.

Codex Medium gave a second opinion. It agreed the bug is still on quattro and that #13007 sends the right keycodes for us,th, and it found no reason not to link them. It could read this review's working notes, so its agreement is not fully independent. This now waits on the maintainer's decision on #13007.

omarchybot avatar Oct 08 '26 09:10 omarchybot

Confirming this on Omarchy 4.0.5-1 with Hyprland 0.56.2-4 (v0.56.2, commit efb50993780079460b0cbed1363e2166a2de1d9f), using standard us,ru layouts.

With Russian active, Super+C / Super+V produced:

Runtime error in lua:
=[C]:-1: send_key_state: key not found

A local override in ~/.config/hypr/bindings.lua that sends XKB keycodes instead of letter names fixed copy/paste. I verified that Super+C/V now work with both English and Russian active:

  • C: code:54
  • V: code:55
  • X: code:53 (included in the override, but cut was not manually verified)

The override preserves the installed terminal behavior (Ctrl+Insert / Shift+Insert) and the existing 50 ms key-release timer. It does not modify package-owned files.

This is additional confirmation for the us,ru case on 4.0.5, rather than a new duplicate issue.

AleksandrBorodavkin avatar Oct 18 '26 16:10 AleksandrBorodavkin

Confirming this still reproduces on Omarchy 4.5.0rc1 (release-candidate channel) with us,ru layout. Pressing SUPER+C/V/X while Russian is active triggers:

Runtime error in lua:
=[C]:-1: send_key_state: key not found

No clipboard action occurs until switching back to English. The workaround remains manual: overriding Universal copy / Universal cut / Universal paste translations in ~/.config/omarchy/locales/ru.json (or injecting by code:NN in clipboard.lua).

PR #13007 is the fix in review but hasn't landed yet. Would be good to get this into the RC before the stable release.

WokoFlipper avatar Oct 23 '26 04:10 WokoFlipper

Still reproduces on the 4.5.0-3 stable release (Hyprland 0.56.2, efb5099) with kb_layout = "us,th". Super+V with Thai active shows send_key_state: key not found and doesn't paste.

Here's a way to reproduce it from a shell without pressing any keys. It shows the uncached-name failure and that code: keycodes avoid it:

hyprctl switchxkblayout all 1   # Thai
hyprctl dispatch 'hl.dsp.send_key_state({ mods = "", key = "K", state = "up" })'        # error: send_key_state: key not found
hyprctl dispatch 'hl.dsp.send_key_state({ mods = "", key = "code:55", state = "up" })'  # ok
hyprctl switchxkblayout all 0

A key name that already resolved once while us was active returns ok even under Thai, because of the keycode cache. That's why it looks intermittent.

Local workaround: in ~/.config/hypr/bindings.lua, o.rebind SUPER+A/C/V/X to send code:38/code:54/code:55/code:53. This only fits QWERTY-based primary layouts. For Colemak/Dvorak users (#14995), #13007's approach of resolving the letters from the primary layout is the right general fix. It would be great to get it merged.

ninyawee avatar Nov 07 '26 03:11 ninyawee

Also reproduces with an Arabic layout: kb_layout = "us,ara" (grp:alts_toggle) on Omarchy 4.5.0-3, Hyprland 0.56.2 (efb5099). With ara active, Super+V shows send_key_state: key not found and nothing is pasted.

Same check from a shell:

hyprctl switchxkblayout all 1   # ara
hyprctl repl 'local r = hl.dispatch(hl.dsp.send_key_state({ mods = "CTRL", key = "V", state = "up" })); return r.ok, r.error'
# false  [C]:-1: send_key_state: key not found
hyprctl repl 'local r = hl.dispatch(hl.dsp.send_key_state({ mods = "CTRL", key = "code:55", state = "up" })); return r.ok'
# true

Overriding Super+A/C/V/X in ~/.config/hypr/bindings.lua with code:38/54/55/53 fixes it here, so the keycode approach in #7375 / #13007 covers this layout too.

mhmodmonim avatar Nov 13 '26 15:11 mhmodmonim

The bug is still present in current quattro: default/hypr/bindings/clipboard.lua passes the named letters A/C/V/X to send_key_state, including the shared o.universal_paste entry point. I read the current source, the new Thai/Arabic confirmations on 4.5.0-3, and the open fix diffs; I did not repeat runtime tests in this issue session.

There is now an explicit fix link: draft PR #18940 includes Fixes #7371. Its latest worker review reports successful shortcuts under Hebrew on the head, with the failure reproduced on base and revert. That review also reports two unresolved regressions: a delayed paste can reach a newly focused panel, and typing after paste can use the wrong layout for longer than on base. #13007 and #18021 remain open alternatives. The follow-up work is on those pull requests; this issue stays open pending the maintainer's decision.

Opus 5.5 High and muse-wonder via pi, thinking high reviewed the same source and reports and agreed with this status. Their independence is not guaranteed. The two runtime findings still need resolution on #18940 by its author or the maintainer.

omarchybot avatar Nov 18 '26 01:11 omarchybot

Confirming on Omarchy 4.5.0-3 (Hyprland 0.56.2, efb5099), kb_layout = "us,ru", with a real GUI check rather than control bytes:

  • Russian active, Ctrl+A / Ctrl+C injected as code:38 / code:54 into a GTK entry (zenity --entry) → wl-paste returns the selected text.
  • Same window, same Russian group, key = "C" → false =[C]:-1: send_key_state: key not found, clipboard unchanged.

So the named-key lookup is the only failure; resolving to code:N is sufficient for real copy/paste. The primary-layout resolver in #13007 (and #18021) is the right shape for non-QWERTY primaries; full validation is in the #13007 comment: https://github.com/omacom/omarchy/pull/13007#issuecomment-7075106803.

For QWERTY primaries, the local workaround already noted here works: o.rebind SUPER+A/C/V/X to code:38/54/55/53 in ~/.config/hypr/bindings.lua.

zxaxqx-design avatar Nov 22 '26 06:11 zxaxqx-design

Thanks for the detailed reports and confirmations, everyone. We're consolidating on one fix: #19868.

When a non-Latin layout is configured, it sends Super+C/V/X/A as the key positions where your Latin layout types those letters, read from Hyprland's live layout settings (so layouts set in ~/.config/hypr/input.lua count too), instead of letter names that Hyprland can't find while a Russian, Ukrainian, Thai, Arabic or similar group is active. Latin-only setups are unchanged.

Testing it on your setup is very welcome; the steps are in this comment on #19868. Please follow up there.

dhh avatar Nov 23 '26 07:11 dhh