sway icon indicating copy to clipboard operation
sway copied to clipboard

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

Open voronind-com opened this issue 1 year ago • 5 comments

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 avatar Jul 28 '24 00:07 voronind-com

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.

emersion avatar Jul 31 '24 18:07 emersion

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 :)

voronind-com avatar Jul 31 '24 19:07 voronind-com

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

emersion avatar Jul 31 '24 20:07 emersion

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).

voronind-com avatar Jul 31 '24 20:07 voronind-com

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 avatar Aug 31 '24 07:08 sahinf

#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.

sahinf avatar Nov 22 '24 20:11 sahinf