Invoking GUI for app running in background with a keypress

Jeremy Moles jeremy at emperorlinux.com
Mon Aug 15 14:20:42 EDT 2005


If you want to get crazy you can poll() on one of the evdev nodes
(/dev/input/event*) and behave accordingly. I do this in a C application
we use to do the exact same thing you're talking about. 

Each successful read from the device returns a 16-byte input_event
struct (or similar, I'm going from memory here) that represents a key
action.

A google search returned this:

http://svn.navi.cx/misc/trunk/python/evdev/evdev.py

On Mon, 2005-08-15 at 12:22 +0200, Mathias Dahl wrote:
> I am creating a small app called PyQe
> (http://klibb.com/cgi-bin/wiki.pl/PyQe) to launch commands and
> programs quickly. I works more or less as I want it now and I have
> managed to make my window manager (Metacity) under Mandrake GNU/Linux
> start my program so that it can be started easily with just a
> keypress.
> 
> Now, the only annoyance I have is that when I have not started the
> program for a while, the OS seems to not have Python or the program in
> "the cache" (or whatever, what I mean is that if I have started the
> program "recently" it starts fast the next time) anymore, which means
> that the program, even though quite small, takes about a second to
> start. This is too slow to feel good given the nature of the program
> (a quick launcher).
> 
> I have tried making it start faster by calling python with the -S
> switch and by compiling my program to a .pyc file. It has not helped
> much.
> 
> So, I was wondering if I could have my program running in the
> background and instead capture a certain keystroke (the same one I
> have my window manager to capture now) to make the GUI appear.
> 
> How does one go about doing this? I found a small program written in C
> (xbindkeys) that can do this and understand that it probably involves
> a lot of "low-level" stuff in X which feels a bit "scary" :). Any
> clues of doing this "easily" in Python + some module?
> 
> /Mathias
> 




More information about the Python-list mailing list