어떤 프로그램이 단축키를 "소유"하는지 알아내는 방법은 무엇입니까?

어떤 프로그램이 단축키를 "소유"하는지 알아내는 방법은 무엇입니까?

저는 커널 4.2.0이 설치된 젠투에서 XFCE 4.12를 실행하고 있습니다. 내 키보드의 PlayPause 버튼은 VLC의 전역 단축키 역할을 했습니다. 이제 VLC는 키도 인식하지 못합니다. "Alt + 미디어 재생 일시 중지"는 표시되지만 개별 키는 표시되지 않습니다.

어떤 프로그램이 해당 키를 캡처했는지 확인할 수 있는 방법이 있나요?

xdotool key "XF86LogGrabInfo"파일을 실행하면 tail /var/log/Xorg.0.log읽습니다.

[ 10138.690] (II) Printing all currently active device grabs:
[ 10138.690] (II) End list of active device grabs

답변1

어떤 응용 프로그램/프로그램이 키를 얻었는지 확인하려면 디버그 키 기호를 사용하세요.XF86LogGrabInfo. xdotool터미널에서 실행할 때와 같이 + 키를 동시에 누르는 데 사용됩니다 .XF86LogGrabInfo

KEY=XF86AudioPlay
xdotool keydown ${KEY}; xdotool key XF86LogGrabInfo; xdotool keyup ${KEY} 

그런 다음 with 및 this가 더 이상 기록되지 않지만 대신에 기록된다는 tail /var/log/Xorg.0.log
점을 사용하여 출력을 확인합니다.gnome 3/gdmsystemdXorg.0.log잡지). 이 경우 실행할 수 있습니다

journalctl -f

그런 다음 다른 터미널에서 명령을 실행하십시오 xdotool. 첫 번째 터미널로 전환하면 다음과 같은 내용이 표시됩니다.

/usr/lib/gdm/gdm-x-session[629]: Active grab 0x40c0a58e (xi2) on device 'Virtual core keyboard' (3):
/usr/lib/gdm/gdm-x-session[629]: client pid 708 /usr/bin/gnome-shell
/usr/lib/gdm/gdm-x-session[629]: at 32595124 (from passive grab) (device frozen, state 6)
/usr/lib/gdm/gdm-x-session[629]: xi2 event mask for device 3: 0xc000
/usr/lib/gdm/gdm-x-session[629]: passive grab type 2, detail 0xac, activating key 172

위의 예에서 키를 얻는 프로그램(클라이언트)은 입니다 gnome-shell.

이 키의 이름을 어떻게 알 수 있나요?

또는 xdotool사용 에 대한 맨페이지를 확인하세요 .man xdotool온라인 버전, 많은 특수 키가 나열되어 있기 때문입니다. 예를 들어 "alt+r", "Control_L+J", "ctrl+alt+n", "BackSpace"입니다. Linux질문 위키에도 있습니다X 키 기호 목록하나를 사용할 수 있습니다. 작업을 더 쉽게 하기 위해 xdotool일부에는 Shift-Alt-Tab과 같은 별칭도 있습니다 shift+alt+Tab. 이것이 실제로 키 조합을 클릭했는지 확인하기 위해 입력을 보낼 수 있으며 xev프로그램은 콘솔에 전달되는 모든 키 또는 마우스 이벤트를 인쇄합니다. 2초가 지나기 전에 sleep 2; xdotool keydown ${KEY}해당 창으로 전환하면 xev해당 창에서 클릭된 키를 볼 수 있습니다. 그런 다음 다음과 같은 일련의 이벤트를 출력해야 합니다.

PropertyNotify event, serial 168, synthetic NO, window 0x1e00001,
    atom 0x13e (_GTK_EDGE_CONSTRAINTS), time 4390512, state PropertyNewValue

MappingNotify event, serial 168, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 168, synthetic NO, window 0x1e00001,
    root 0x163, subw 0x0, time 4390719, (882,657), root:(1000,771),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 169, synthetic NO, window 0x1e00001,
    root 0x163, subw 0x0, time 4390738, (882,657), root:(1000,771),
    state 0x8, keycode 23 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XmbLookupString gives 1 bytes: (09) "   "
    XFilterEvent returns: False

답변2

다음 명령은 키보드 단축키를 사용하는 모든 프로그램을 식별하는 데 도움이 되었습니다.

$ lsof -c Xorg | grep ".log" # find out the path for the Xorg log file
Xorg    16025   sr    4w      REG              254,1    225839 3933229 /home/sr/.local/share/xorg/Xorg.0.log
$ xdotool key XF86LogGrabInfo # prints all Xorg registered grabs
$ cat /home/sr/.local/share/xorg/Xorg.0.log | grep grabs
[ 39303.019] (II) Printing all currently active device grabs:
[ 39303.019] (II) End list of active device grabs
[ 39303.019] Printing all currently registered grabs
[ 39303.019]   Printing all registered grabs of client pid 16024 xinit /home/sr/.xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.6AO52I3zhe
[ 39303.019]   Printing all registered grabs of client pid 16045 unclutter 
[ 39303.019]   Printing all registered grabs of client pid 16047 xscreensaver 
[ 39303.019]   Printing all registered grabs of client pid 16109 /usr/lib/firefox/firefox 
[ 39303.019]   Printing all registered grabs of client pid 16055 xscreensaver-systemd 
[ 39303.019]   Printing all registered grabs of client pid 16057 xbindkeys 
[ 39303.027]   Printing all registered grabs of client pid 16039 /usr/bin/openbox --startup /usr/lib/openbox/openbox-autostart OPENBOX
[ 39303.039]   Printing all registered grabs of client pid 16048 copyq 
[ 39303.039]   Printing all registered grabs of client pid 16049 konsole 
[ 39303.039]   Printing all registered grabs of client pid 16095 /usr/bin/copyq --clipboard-access monitorClipboard
[ 39303.039]   Printing all registered grabs of client pid 16109 /usr/lib/firefox/firefox 
[ 39303.039]   Printing all registered grabs of client pid 16456 subl --detached
[ 39303.039]   Printing all registered grabs of client pid 16465 /usr/lib/at-spi2-registryd --use-gnome-session
[ 39303.039]   Printing all registered grabs of client pid 17178 xdotool key XF86LogGrabInfo
[ 39303.039] End list of registered passive grabs

그래서 내 경우에는 다음 응용 프로그램에 키 바인딩이 적용됩니다: xinit, unclutter, xscreensaver, firefox, xbindkeys, openbox, copyq, konsole, subl, at-spi2-registryd

관련 정보