Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindsym --to-code not working with non-modifier keys. #8267

Open
voronind-com opened this issue Jul 28, 2024 · 6 comments
Open

Bindsym --to-code not working with non-modifier keys. #8267

voronind-com opened this issue Jul 28, 2024 · 6 comments
Labels
bug Not working as intended

Comments

@voronind-com
Copy link

voronind-com commented Jul 28, 2024

Please fill out the following:

  • Sway Version:
    1.9

  • Configuration File:
    bindsym --to-code print+a exec firefox won't work with other layouts.

  • Description:
    Currently Sway won't work if you use key combos with non-modifier keys (unlike shift, meta etc). Would be nice to support that as I use Print key as an extra modifier for Sway.

@voronind-com voronind-com added the bug Not working as intended label Jul 28, 2024
@emersion
Copy link
Member

I don't see a reason why it wouldn't work.

The --to-code option makes it so Sway sticks to a specific physical key regardless of the keyboard layout.

@voronind-com
Copy link
Author

I don't see a reason why it wouldn't work.

The --to-code option makes it so Sway sticks to a specific physical key regardless of the keyboard layout.

Yeah I guess. Thats why the Bug label :)

@emersion
Copy link
Member

Not sure what you mean… What is the behavior you see, and what is the behavior you'd expect?

@voronind-com
Copy link
Author

Not sure what you mean… What is the behavior you see, and what is the behavior you'd expect?

The example I provided does not work. I expect it to work just like my other keybinds that use, say, Mod4. All I'm saying that Mod4+a works for me and print+a does not (in non-latin layout).

@sahinf
Copy link
Contributor

sahinf commented Aug 31, 2024

I ran into this issue on the tr layout too.
Debug log tidbit : [sway/commands/bind.c:722] Unable to convert keysym 65377 into a single keycode (found 2 matches)

How come sway prohibits multiple keycodes per keysym? The docs say libxkbcommon supports multiple key symbols per level.

I don't fully understand how xkb works but I see that the "2nd match" is probably coming from /usr/share/X11/xkb/keycodes/evdev

default xkb_keycodes "evdev" {
...
	<PRSC> = 107;
...
	// Key codes below are autogenerated
	<I218> = 218;		// #define KEY_PRINT               210
...
}

Because both of those keycodes return the keysymbol for #define XKB_KEY_Print 0xff61:

(gdb) print xkb_state_key_get_one_sym(config->keysym_translation_state, 107)
$8 = 65377
(gdb) print xkb_state_key_get_one_sym(config->keysym_translation_state, 218)
$9 = 65377
(gdb) bt
#0  cmd_bindsym (argc=6, argv=0x5555561324e8) at ../sway/commands/bind.c:577
#1  0x000055555556dc9f in config_command (exec=0x55555618b3a0 "bindsym --to-code Print exec ~/bin/script-testing.sh notify-brightness up", new_block=0x7fffffffdfc8)
    at ../sway/commands.c:426
#2  0x0000555555570e2d in read_config (file=0x55555614a4c0, config=0x55555614f8c0, swaynag=0x55555614f8c8) at ../sway/config.c:824
#3  0x000055555556fa9b in load_config (path=0x5555560a20c0 "/home/furkan/.config/sway/config", config=0x55555614f8c0, swaynag=0x55555614f8c8) at ../sway/config.c:437
#4  0x000055555556fe75 in load_main_config (file=0x0, is_active=false, validating=false) at ../sway/config.c:509
#5  0x000055555557d283 in main (argc=1, argv=0x7fffffffe2d8) at ../sway/main.c:351

65377 = 0xff61

@sahinf
Copy link
Contributor

sahinf commented Nov 22, 2024

#8358 closes this issue just needs to merge, but feel free to cherry pick it. I've been running that commit without issues so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

Successfully merging a pull request may close this issue.

3 participants