[Haskell-cafe] How to create a background program that monitors input (linux)

Brandon Allbery allbery.b at gmail.com
Tue Apr 29 23:59:06 UTC 2014

On Tue, Apr 29, 2014 at 11:25 AM, Brandon Allbery <allbery.b at gmail.com>wrote:

> I never came across a way to simply monitor arbitray keypresses from a
> background program and take action depending on them. For instance running
> a system command whenever ctrl+alt+r is pressed.

I should mention that this mechanism you're trying to use does not exist in
Xlib. It can be done via the RECORD extension. I do not recommend it; among
other things, X11 does not give programs "veto control" of event delivery
--- so you could in theory use RECORD to do this (with significantly
increased load over using the proper mechanism since you are seeing all key
events) but you cannot prevent the triggering key(s) from also being
delivered to the focused window. This is the wrong mechanism entirely for
such things, operates at the wrong level, and is expensive (and potentially
a security issue; consider what "all key events" means; this also means
that the RECORD extension is often disabled in the interest of security).

brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140429/05b13b41/attachment.html>

More information about the Haskell-Cafe mailing list