[Xcb] I’m writing a launcher and I need to capture the keyboard

Alexander Teinum ateinum at gmail.com
Wed Mar 21 07:53:43 PDT 2012


Hi.

I’m currently developing a launcher in Go that’s using X Go bindings.
I’m not sure if it’s a wrapper around XCB or if it is a
reimplementation of the XCB API in Go. I think the solution to my
problem isn’t tied to what library I’m using. This has more to do with
how X works.

What I want to accomplish is to have a launcher program that, once
itself is launched, should capture the keyboard while blocking
keyboard input from other applications, until the user presses enter
or escape. Another requirement is that the launcher should not be
visible on the screen.

So far I have managed to write a launcher that simply captures the
keyboard in a window[1] by subscribing to the KeyPress-event for that
window and setting window class to InputOutput. I’ve experimented with
setting the window class to InputOnly, but it didn’t capture keyboard
events. I have also played around with override-redirect, but I
couldn’t get things to work with that either.  I also tried using
GrabKeyboard on the root window, and it worked when the launcher was
launched from a terminal (uxterm), but I use my window manager (dwm)
to launch my launcher.

Any help regarding this would be super-useful.


1. https://github.com/alexanderte/de/blob/master/main.go


More information about the Xcb mailing list