Invoking GUI for app running in background with a keypress
Mathias Dahl
brakjoller at gmail.com
Mon Aug 15 16:59:39 EDT 2005
Jeremy Moles <jeremy at emperorlinux.com> writes:
> 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
Thanks for the pointer. That sounds crazy indeed! Maybe a bit too
crazy (low-level) for me... :)
I tested the code very briefly:
$ python evdev.py /dev/input/event0
Traceback (most recent call last):
File "evdev.py", line 549, in ?
demo()
File "evdev.py", line 35, in demo
dev = Device(sys.argv[1])
File "evdev.py", line 91, in __init__
self.fd = os.open(filename, os.O_RDWR | os.O_NONBLOCK)
OSError: [Errno 13] Permission denied: '/dev/input/event0'
Loggin in (su:ing) as root solves that problem but I'm not sure I want
to require the user being root to be able to run my program.
Anyway, thanks again for the hint!
/Mathias
More information about the Python-list
mailing list