Skip to content

feat(sway): bind shortcuts by keycode with --to-code - #262

Open
QuentinCazier wants to merge 2 commits into
cloud-gouv:mainfrom
QuentinCazier:sway-to-code
Open

QuentinCazier wants to merge 2 commits into
cloud-gouv:mainfrom
QuentinCazier:sway-to-code

Conversation

@QuentinCazier

@QuentinCazier QuentinCazier commented Sep 11, 2026

Copy link
Copy Markdown

Closes #84

Sway bindings were declared by keysym, so a keyboard set to another layout than fr ends up with the workspace and letter shortcuts on different physical keys.

This adds --to-code to every bindsym of the shipped config. Sway resolves each keysym to its keycode from the first input block that declares an xkb_layout, here type:keyboard with fr, so the shortcuts stay on the same physical keys whatever layout is active on the keyboard. The bindings stay in the main config, so they remain overridable without an extra config file.

Note on how sway picks the reference layout: the translation uses the first layout of the first input block that declares one. A shared xkb_layout "fr,us" with a layout switch works as expected. A per device override such as input <id> xkb_layout us becomes that reference instead, so this case is not covered by the change.

Test

tests/sway-keybindings.nix boots the Securix sway configuration in a VM and sends key events through QEMU: Mod+Return, Mod+Shift+q and Mod+2 on the fr layout, then Mod+3, Mod+Return and Mod+Shift+q after switching the keyboard to us. On main the us part fails, with this change both parts pass.

nixfmt, statix and reuse pass on the new files.

The sway configuration binds shortcuts by keysym, so on a keyboard using
another layout than fr the workspace keys and letter shortcuts land on
different physical keys.

Using bindsym --to-code translates each keysym to its keycode from the
first configured layout (fr), so the same physical keys work on both fr
and en keyboards without carrying the bindings in an extra config.

Closes cloud-gouv#84

Signed-off-by: Quentin Cazier <cazierquentin@gmail.com>
Boots the Securix sway configuration and sends key events through QEMU.
The shortcuts must react on the same physical keys with the default fr
layout and once the keyboard is switched to a us layout.

Signed-off-by: Quentin Cazier <cazierquentin@gmail.com>
@QuentinCazier
QuentinCazier marked this pull request as ready for review September 11, 2026 16:48
@jdauphant-dinum jdauphant-dinum added the status: awaiting-maintainers This is blocked on a maintainer's review bandwidth label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: awaiting-maintainers This is blocked on a maintainer's review bandwidth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sway: support both fr and en keyboards

2 participants