Fix send_key_state errors on SUPER+C/V/X with a non-Latin layout active
Symptom
With a multi-layout keyboard (kb_layout = "us,th", us,ru, us,ua ...), pressing SUPER+C / 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 or pasted. It works in the English layout. Oddly, once it succeeds in English after a Hyprland reload, it keeps working in the other layout until the next reload.
Cause
Hyprland's resolveKeycode maps a key name like "C" to a keycode by scanning the keymap with the currently active layout group applied. A non-Latin group contains no Latin keysyms, so "C" is never found and the dispatcher raises a Lua runtime error. The keycode cache key does not include the layout group, which is why one success in Latin makes it work afterwards.
Fix
Bind by keycode instead of key name. Keycodes are layout-independent. XKB keycodes are evdev+8, so C/V/X are code:54, code:55, code:53.
-- ~/.config/hypr/bindings.lua
hl.unbind("SUPER + C")
hl.unbind("SUPER + V")
hl.unbind("SUPER + X")
hl.bind("SUPER + C", function()
hl.dispatch(hl.dsp.send_key_state({ mods = "CTRL", key = "code:54", state = "down" }))
hl.timer(function()
hl.dispatch(hl.dsp.send_key_state({ mods = "CTRL", key = "code:54", state = "up" }))
end, { timeout = 50, type = "oneshot" })
end)
The simplest alternative is to drop the universal shortcuts and use the apps' native CTRL+C/V/X:
-- ~/.config/hypr/bindings.lua
hl.unbind("SUPER + C")
hl.unbind("SUPER + V")
hl.unbind("SUPER + X")
Confirm keycodes for your keyboard with wev (the code field it prints is the XKB keycode).
Verify
Switch to the non-Latin layout, select text, press SUPER+C. No error popup and wl-paste returns the selection.