What command line tools exist to list and manage X server grabs? (That's grab as in key and pointer grabs, i.e. restricting the use of a particular key or mouse button to a particular application, or constricting the mouse pointer to remain in a particular screen area.) I'm looking for a hypothetical xgrab utility that would show things like

Key     0x00f00ba5  0x123   0
Button  0x00f00ba5  2       
Pointer 0x00abcdef  

meaning that there has been a call to XGrabKey(display, 0x123, 0, 0x00f00ba5, ...) and so on with XGrabButton, XGrabPointer, XGrabKeyboard, XGrabServer (if possible). The display format doesn't matter, what I want is some way to see who's grabbing what, and possibly some way of revoking these grabs (if it's possible, I'm not sure if the X11 API allows that).


Recent versions of X (X.org server ≥1.11) support several debugging keysyms, introduced in this commit. When triggered, these perform actions related to grabs.

By default (at least in recent versions), these are disabled (absent from the default keymap).

However, if you have xdotool installed, it is possible to call them, by executing on the command-line:

xdotool key NameOfKey

where NameOfKey is the keysym you want to activate. For example, to print a list of active grabs to the X server log, use xdotool key XF86LogGrabInfo.

Relevant keysyms are:

Note that XF86LogGrabInfo only lists active grabs, not passive grabs such as a grab on a key which isn't currently pressed. If you want to get information about a passive grab, you need to activate the grab: run xdotool key XF86LogGrabInfo while the key chord or mouse button combination you're interested in is pressed. Do something like:

  1. Run sleep 1; xdotool key XF86LogGrabInfo
  2. Within 1 second, press the key chord or mouse button combination.
  3. After 1 second, release the key/button.
  4. Check the “Active grab …” information in the X server log (often /var/log/Xorg.0.log).
  • 2
    Testing now on Debian wheezy with Xorg 1.12.4, xdotool key XF86LogGrabInfo triggers only two entries in the X log: “Printing all currently active device grabs:” immediately followed by “End list of active device grabs”. Yet my window manager does grab a bunch of keys. Have you seen this work for grabbed keys? – Gilles 'SO- stop being evil' Nov 16 '14 at 23:15
  • 4
    @Gilles - no, you won't get any output if you run it like that... try running it with sleep 2; xdotool key "XF86LogGrabInfo" and immediately start pressing a key (e.g. the "Win" key) very fast, then you'll see some output in Xorg.log. Or use xdotool to press keys + XF86LogGrabInfo at the same time, like here – don_crissti Nov 25 '14 at 0:58
  • @don_crissti Ah, I see, XF86LogGrabInfo only prints information about a key that is currently pressed? That limits its usefulness. I want to list all the grabs — all the passive grabs, if I understand the terminology correctly. – Gilles 'SO- stop being evil' Nov 25 '14 at 10:13
  • There's probably some clever way of combining this with a scripted exhaustive search of key combinations, hopefully without a virtual keyboard. Certainly outside my knowledge. – Adam Katz Jan 16 '15 at 17:18
  • Thanks! This helped me discover that xfsettingsd was stealing my Win + L shortcut. – Mikel May 13 '15 at 6:52

I don't know of anything off hand for the passive grabs1 of a single key or button that may be present, but there are a couple ways to list active grabs of an entire keyboard or mouse device.

  1. On all platforms, but only with Xorg 1.11 and later (or an older version with the patch applied), map hotkeys to dump grab data to the log as described in these patch notes.
  2. On Solaris 11 (either Solaris 11 Express 2010.11 or the actual Solaris 11 release), use the debugger scripts such as /usr/demo/Xserver/mdb/list_Xserver_devicegrab_client, as described in Grabbing Information from the X Server. There's also one here for server grabs, which the Xorg 1.11 hotkeys don't currently cover.

1 See http://tronche.com/gui/x/xlib/input/pointer-grabbing.html for definition of active vs. passive grabs.


This is an addition to Mechanical snail's answer --

The entries in the Xorg log can be pretty undecipherable. I wrote a program which parses them and presents them in a human-tractable form:


To use, first run xdotool key XF86LogGrabInfo, as described in Mechanical snail's answer. Then, run the program linked above. If you Xorg log file is not located at /var/log/Xorg.0.log, you can specify its location using the --xorg-log option. See --help for details.

  • 3
    The gist mentioned here is programmed in language D. To get an executable file, one can install packages gdc (GNU D compiler) and libx11-dev then run gdc -o xorg-show-grabs xorg-show-grabs.d -lX11. – Stéphane Gourichon May 29 '18 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.