键盘快捷键会间歇性地停止工作

编辑:从答案中可以看出,这实际上与待机或hibernate无关,而是在与大部分时间进入待机状态之前经常关闭应用程序窗口(触发错误)时与我相关。

我看到有很多人在网上的各个地方报告这个,没有任何解决方案,但我想在任何情况下我都会添加我的:

很多时候,在一段时间后(当它进入待机状态时)返回计算机后,我注意到一些快捷方式已停止工作。 这不仅发生在终端,也发生在Chrome中(Ctrl-L,Ctrl-R,F5都停止工作)。 它也不会影响所有ctrl-shortcuts:例如Ctrl-C仍在工作(感谢上帝!)。

有没有办法调试这个? 早点尝试xev并没有把我xev任何地方,但也许有一些方法可以找出阻止我的按键到达程序的原因?

编辑:我可以通过Ctrl-R看到一些奇怪的事情

有些东西正在抓住键盘快捷键!

xev捕获的输出

 KeyPress event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24547557, (-130,529), root:(0,633), state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False FocusOut event, serial 37, synthetic NO, window 0x5200001, mode NotifyGrab, detail NotifyAncestor FocusIn event, serial 37, synthetic NO, window 0x5200001, mode NotifyUngrab, detail NotifyAncestor KeymapNotify event, serial 37, synthetic NO, window 0x0, keys: 4294967278 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 KeyRelease event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24548550, (-130,529), root:(0,633), state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False 

将其与Ctrl-C进行比较

我们可以很容易地看到这里发生的四个逻辑事件

 KeyPress event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24724066, (572,852), root:(702,956), state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24724818, (572,852), root:(702,956), state 0x14, keycode 54 (keysym 0x63, c), same_screen YES, XLookupString gives 1 bytes: (03) "" XmbLookupString gives 1 bytes: (03) "" XFilterEvent returns: False KeyRelease event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24724966, (572,852), root:(702,956), state 0x14, keycode 54 (keysym 0x63, c), same_screen YES, XLookupString gives 1 bytes: (03) "" XFilterEvent returns: False KeyRelease event, serial 37, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 24725339, (572,852), root:(702,956), state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False 

我设法找到了最不可能的罪魁祸首: Caprine Messenger应用程序。 ! 使用Electron框架(Spotify,Atom,VS Code)制作的许多其他应用程序也可能发生这种情况,直到修复了快捷方式库中的错误 。

我现在知道如何在阅读电子问题跟踪器上的错误报告后一致地重现错误:只需关闭应用程序,使其只是驻留在系统托盘中。 但在我到达那里之前,我设法找到了确凿的证据,certificate正是Caprine正在抓住捷径并且杀死它解决了这个问题。 这就是我发现的方法(可用于类似情况):

对这个重复问题的一个不太明显的答案解释说,有可能通过发出一些魔术击键来检测哪个应用程序正在抓取键。 起初我不太明白如何设置它,认为我必须经历各种各样的箍(弄乱Xorg配置,禁用vty切换,++)来设置一个特殊的键映射配置,直到它突然出现在我身上答案实际上还描述了如何以编程方式触发这些键组合!

所以我需要做的就是打开两个终端窗口。 在第一个终端窗口中,我开始在Xorg系统中记录事件:

 tail -f /var/log/Xorg.0.log > out.txt 

在另一个窗口中,我触发了将键组合发送到Xorg系统的事件:

 KEY="ctrl+r" # the combination that was "grabbed" xdotool keydown ${KEY}; # start pressing the key combo xdotool key XF86LogGrabInfo; # the keysym that when emitted asks X to print info on the grabber of the current keys xdotool keyup ${KEY} # stop pressing the key combo 

像这样以编程方式执行此操作要比手指章鱼手动操作容易得多:-)在另一个窗口(13’000行!)中捕获的事件日志中,有趣的位在前几行显而易见:

 [ 24264.517] detail 71 (mask 0), modifiersDetail 128 (mask 0) [ 24264.517] device 'Virtual core keyboard' (3), modifierDevice 'Virtual core keyboard' (3) [ 24264.517] core event mask 0x3 [ 24264.517] owner-events false, kb 1 ptr 1, confine 0x0, cursor 0x0 [ 24264.517] Printing all registered grabs of client pid 5643 /opt/Caprine/caprine --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,23,59,71 --gpu-vendor-id=0x8086 --gpu-device-id=0x5916 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --service-request-channel-token=B68A5099B5760C39675F51019B3D4F7A --v8-natives-passed-by-fd --v8-snapshot-passed-by-f [ 24264.517] Printing all registered grabs of client pid 5643 /opt/Caprine/caprine --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,23,59,71 --gpu-vendor-id=0x8086 --gpu-device-id=0x5916 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --service-request-channel-token=B68A5099B5760C39675F51019B3D4F7A --v8-natives-passed-by-fd --v8-snapshot-passed-by-f [ 24264.517] Printing all registered grabs of client pid 5684 /usr/lib/slack/slack --disable-gp [ 24264.517] Printing all registered grabs of client pid 5684 /usr/lib/slack/slack --disable-gp [ 24264.517] Printing all registered grabs of client pid 18336 xdotool key XF86LogGrabInfo [ 24264.517] End list of registered passive grabs [ 24308.177] (II) Printing all currently active device grabs: [ 24308.177] Active grab 0x44800160 (core) on device 'Virtual core keyboard' (3): [ 24308.177] client pid 5614 /opt/Caprine/caprine [ 24308.177] at 24308139 (from passive grab) (device thawed, state 1) [ 24308.177] core event mask 0x3 [ 24308.177] passive grab type 2, detail 0x1b, activating key 27 [ 24308.177] owner-events false, kb 1 ptr 1, confine 0, cursor 0x0 [ 24308.177] (II) End list of active device grabs 

杀死Caprine后,我终于可以再次在终端中使用Ctrl-R进行反向历史搜索,以及刷新Chrome! xev还输出了与我在问题中详述的内容完全不同的内容,现在与Ctrl-L的输出非常相似:

 KeyPress event, serial 39, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 25356738, (917,877), root:(1047,981), state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 39, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 25357181, (917,877), root:(1047,981), state 0x14, keycode 27 (keysym 0x72, r), same_screen YES, XLookupString gives 1 bytes: (12) "" XmbLookupString gives 1 bytes: (12) "" XFilterEvent returns: False KeyRelease event, serial 39, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 25357315, (917,877), root:(1047,981), state 0x14, keycode 27 (keysym 0x72, r), same_screen YES, XLookupString gives 1 bytes: (12) "" XFilterEvent returns: False KeyRelease event, serial 39, synthetic NO, window 0x5200001, root 0xee, subw 0x0, time 25357710, (917,877), root:(1047,981), state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False 

编辑:原来这个bug已知

错误问题还显示了如何始终如一地重现(最小化)。 它是由电子localshortcut库中的一个错误引起的。


制作一个小的工具,以编程方式轻松发送这些快捷方式。