r-c-f/waynergy

Issue: [raw-keymap] cannot unbind left arrow key from system shutdown

moghingold opened this issue · 7 comments

Host: Mac OS
Client: Arch linux with KDE

Reproduction steps:

  • Hit the 'left' arrow key on the host machine's keyboard

Expected result:

  • Client running waynergy should register 'left' arrow

Actual result:

  • Client computer immediately shuts down

Mitigations attempted:

  • Using waynergy-mapper -r I have attempted to create a custom keymap for waynergy running with KDE. However, when I skip everything except the direction arrows and right click, nothing is output (I supply the input for "left" with my laptop keyboard to prevent shutdown during waynergy-mapper's execution).
  • After copying the output of waynergy-mapper into ~/.config/waynergy/config.ini, I have tried manually appending 113 = 113, since my hypothesis is that the first mitigation outputs nothing when there is no disagreement between the keypress received and the keypress requested and experimentation revealed 113 to be the raw mapping for the left arrow key on the keyboard laptop. This seems to do nothing.
  • I have tried disabling all keyboard shortcuts in KDE (literally all of them). The left arrow key still shuts down the machine when it is connected as a waynergy client.

Mitigations not attempted:

  • Just, like, never using the left arrow key, I guess.
r-c-f commented

When using a hardware keyboard, what is the key code registered by xev/wev for normal (ie not shutting down) left arrow?

When you say hardware keyboard, do you mean plugging this USB keyboard directly into my Linux box or do you mean the Linux box's built-in keyboard (since it's a laptop)? I'll try both and hope you wanted at least one of them:

Plugging the keyboard directly into the laptop:

[14:     wl_keyboard] key: serial: 13284; time: 21200041; key: 113; state: 1 (pressed)
                      sym: Left         (65361), utf8: ''
[14:     wl_keyboard] key: serial: 13285; time: 21200110; key: 113; state: 0 (released)
                      sym: Left         (65361), utf8: ''

The laptop's own left arrow key:

[14:     wl_keyboard] key: serial: 13645; time: 21297606; key: 113; state: 1 (pressed)
                      sym: Left         (65361), utf8: ''
[14:     wl_keyboard] key: serial: 13646; time: 21297675; key: 113; state: 0 (released)
                      sym: Left         (65361), utf8: ''
r-c-f commented

Could you post the waynergy output with -L debug when this happens, as well as the full keymap that waynergy-mapper generated?

Where does waynergy write its logs so I can send you the output after the computer shuts down? Should I just redirect it eg: waynergy -L debug > foo.txt 2>&1? Unless directed otherwise before my kernel finishes building that is what I will try, and report back.

Before I make my laptop shut down, here is the raw keymap that is currently in config.ini. Please pay no attention to the numlock and kp_enter entries, that's another issue.

[raw-keymap]
54 = 9
19 = 10
20 = 11
21 = 12
22 = 13
24 = 14
23 = 15
27 = 16
29 = 17
26 = 18
30 = 19
28 = 20
25 = 21
52 = 22
49 = 23
13 = 24
14 = 25
15 = 26
16 = 27
18 = 28
17 = 29
33 = 30
35 = 31
36 = 33
31 = 35
37 = 36
60 = 37
1 = 38
2 = 39
3 = 40
4 = 41
6 = 42
5 = 43
39 = 44
41 = 45
38 = 46
42 = 47
40 = 48
51 = 49
57 = 50
43 = 51
7 = 52
8 = 53
9 = 54
10 = 55
12 = 56
46 = 57
47 = 58
44 = 59
48 = 60
45 = 61
57 = 62
68 = 63
59 = 64
50 = 65
58 = 66
123 = 67
121 = 68
100 = 69
119 = 70
97 = 71
98 = 72
77 = 104
72 = 77
99 = 73
101 = 74
102 = 75
110 = 76
108 = 78
90 = 79
92 = 80
93 = 81
79 = 82
87 = 83
88 = 84
89 = 85
70 = 86
84 = 87
85 = 88
86 = 89
83 = 90
66 = 91
104 = 95
112 = 96
60 = 105
76 = 106
106 = 107
59 = 108
116 = 110
127 = 111
125 = 114
120 = 115
126 = 116
115 = 118
118 = 119
0 = 121
0 = 122
0 = 123
114 = 127
56 = 133
56 = 134
111 = 135
113 = 113

Running waynergy with the following command:

/usr/bin/waynergy -b kde -e -t -L debug 2>&1 | tee /home/moghingold/.config/waynergy/waynergy-debug.log

I get the following debug output right before the computer shuts down:

298.874354896: [DEBUG] Modifiers: depressed: 0 latched: 0 locked: 0 group: 0
298.874371047: [DEBUG] Keycode: 124, state 1
298.933081293: [DEBUG] Modifiers: depressed: 0 latched: 0 locked: 0 group: 0
298.933096482: [DEBUG] Keycode: 124, state 0
300.452811456: [DEBUG] Got CALV

So it looks like the 'left' arrow key is being mapped to 124 instead of 113 when it's coming over Barrier from on the Mac. Unsurprisingly, waynergy-mapper reports that key 124 is the POWR key and maps to XF86PowerOff. Appending 124 = 113 to the end of the raw-keymap section of config.ini fixed this issue.

r-c-f commented

I'm thinking that the actual resolution of this will be a change such that waynergy-mapper operates at the network level rather than as a simple wayland client. That would prevent any unfortunate erroneous bindings from being triggered in the compositor.