Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3247

nsa325 copy button event (no replies)

$
0
0
Hi all,

i have some problems catching the copy button press event.

Buttzy10169 wrote on December 08, 2013 this comment:

Quote
Buttzy10169
And the following python script lets you do something with the copy button:

from evdev import InputDevice
from select import select
from subprocess import call

dev = InputDevice('/dev/input/event0')

while True:
        r,w,x = select([dev], [], [])
        for event in dev.read():
                if event.code == 133:
                        call(["shutdown", "-r", "now", "\"this is a test\""])

The problem is, there are two events happening, so my script is beeing executed two times.
It seems, "buttondown" and "buttonup" are catched by the script.
I thought, it might be useful to add a sleep command after the last line, but the events seem to be cached and appear after the sleep.

What could be done now? I added a "print event.code" line to the code; these are the events, when pressing and releasing the button:
Event Code: 133
Event Code: 0
Event Code: 133
Event Code: 0

There are even 4 events ... now thats weird ....

Viewing all articles
Browse latest Browse all 3247

Trending Articles