swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.65k stars 1.11k forks source link

`--input-device` makes `bindsym` echo keys #6961

Open thedmm opened 2 years ago

thedmm commented 2 years ago

Running Arch Linux, sway version 1.7. I use multiple keyboards (a built-in one, and an external programmable one), and I have a different set of keybindings for each. As such, I decided to specify --input-device for every bindsym invocation. Turns out that adding --input-device subtly changes the behavior of the binding: activations of keyboard-specific bindings are not consumed by sway, and get passed down to applications.

Steps

  1. Open Sway.
  2. Check the current keyboard (e.g. via swaymsg -t get_inputs).
  3. Add a new binding specific to the keyboard (e.g. swaymsg bindsym --input-device=<ID> Mod4+a nop).
  4. Add a new binding for all keyboards (e.g. swaymsg bindsym Mod4+b nop).
  5. Open a program such as fish inside kitty (cat -v is likely the best bet - fish can be configured to handle ESC).
  6. Try both keybindings.
  7. Note that the keyboard-specific one results in input to the program (e.g. [97;9u is printed), where as the non-specific one does not.

Configuration

Here is a sample configuration file which shows this issue (replace <ID> appropriately):

bindsym Mod4+t exec kitty
bindsym Mod4+e exit
bindsym --input-device=<ID> Mod4+a nop
bindsym Mod4+b nop

Simply open Sway with this file, activate Mod4+t, (open cat -v), Mod4+a, Mod4+b, note the difference in output, close the shell, and exit with Mod4+e.

Log

I have a log, but due to the excess amount of low-level information therein, I would rather not upload it. Here are what appear to be the most relevant snippets:

00:00:00.064 [INFO] [sway/config.c:407] Loading config from config
00:00:00.064 [DEBUG] [sway/config.c:824] Read line 1: bindsym Mod4+t exec kitty
00:00:00.064 [INFO] [sway/commands.c:378] Config command: bindsym Mod4+t exec kitty
00:00:00.064 [INFO] [sway/commands.c:398] After replacement: bindsym Mod4+t exec kitty
00:00:00.064 [DEBUG] [sway/commands/bind.c:298] bindsym - Bound Mod4+t to command `exec kitty` for device '*'
00:00:00.064 [DEBUG] [sway/config.c:824] Read line 2: bindsym Mod4+e exit
00:00:00.064 [INFO] [sway/commands.c:378] Config command: bindsym Mod4+e exit
00:00:00.064 [INFO] [sway/commands.c:398] After replacement: bindsym Mod4+e exit
00:00:00.064 [DEBUG] [sway/commands/bind.c:298] bindsym - Bound Mod4+e to command `exit` for device '*'
00:00:00.064 [DEBUG] [sway/config.c:824] Read line 3: bindsym --input-device=<ID> Mod4+a nop
00:00:00.064 [INFO] [sway/commands.c:378] Config command: bindsym --input-device=<ID> Mod4+a nop
00:00:00.064 [INFO] [sway/commands.c:398] After replacement: bindsym --input-device=<ID> Mod4+a nop
00:00:00.064 [DEBUG] [sway/commands/bind.c:298] bindsym - Bound Mod4+a to command `nop` for device '<ID>'
00:00:00.064 [DEBUG] [sway/config.c:824] Read line 4: bindsym Mod4+b nop
00:00:00.064 [INFO] [sway/commands.c:378] Config command: bindsym Mod4+b nop
00:00:00.064 [INFO] [sway/commands.c:398] After replacement: bindsym Mod4+b nop
00:00:00.064 [DEBUG] [sway/commands/bind.c:298] bindsym - Bound Mod4+b to command `nop` for device '*'
...
00:00:05.264 [DEBUG] [sway/commands/bind.c:617] running command for binding: nop
00:00:05.264 [INFO] [sway/commands.c:258] Handling command 'nop'
00:00:06.648 [DEBUG] [sway/commands/bind.c:617] running command for binding: nop
00:00:06.648 [INFO] [sway/commands.c:258] Handling command 'nop'
Schnouki commented 2 years ago

I have the same issue, and I think it's actually a duplicate of #4955. In any case, adding seat * keyboard_grouping none in my config fixed it for me. (Sway 1.7, Arch Linux, using internal laptop keyboard in fr-oss layout and external keyboard with a custom US-based layout)

fulax commented 2 years ago

In any case, adding seat * keyboard_grouping none in my config fixed it for me.

Thanks for the workaround, works for me too !