Listening for keypress in the background

Mathias Dahl brakjoller at
Sun Oct 23 03:02:43 CEST 2005

Mathias Dahl <brakjoller at> writes:

> Peter Hansen <peter at> writes:
>>> How can I make it listen for a certain keypress (say, Windows-key +
>>> space) in a controlled fashion even when it is not the program having
>>> focus?
>>> I need to do this running under GNOME in Mandrake GN/Linux 10.
>> Search Google for "python keylogger".
> Thanks, good idea! The relevant pages I found only link to
> Windows-specific keyloggers though.
> I just got another idea on a solution for my main problem (invoking my
> sleeping app) and that would be to let my window manager execute a
> small "invoker" program that would communicate with the sleeping
> app. The question is, which is the easiest way to communicate with a
> running Python program? Signals? TCP/IP (not really, right?) Pipes?

I solved it using named pipes (mkfifo, open and read) plus a simple
echo x > pipe to invoke.

More information about the Python-list mailing list