Welcome! Log In Create A New Profile


nsa325 copy button event

Posted by ptosch 
nsa325 copy button event
February 01, 2017 11:08AM
Hi all,

i have some problems catching the copy button press event.

Buttzy10169 wrote on December 08, 2013 this comment:

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 ....

Edited 1 time(s). Last edit at 02/01/2017 11:09AM by ptosch.
Re: nsa325 copy button event
February 01, 2017 04:03PM

Instead of the input script (which was deprecated long ago in Linux), you can install esekeyd (multimedia keyboard daemon for Linux). It is way better.

apt-get install esekeyd

And set it up in the conf file. Here is my test version, where the button push will print out to syslog. Replace it with your own action or scripts to do certain things such as shutdown, backup,....

cat /etc/esekeyd.conf
POWER:/usr/bin/logger -s -i "POWER button pushed"
RESTART:/usr/bin/logger -s -i "RESTART button pushed"
COPY:/usr/bin/logger -s -i "COPY Button pushed"

latest Kirkwood kernel builds and rootfs
latest u-boot-kirkwood builds
latest Oxnas kernel builds and rootfs
latest u-boot-oxnas builds
latest MVEBU Armada kernel builds and rootfs
U-Boot & Kernel Booting process
bodhi's u-boot GitHub
bodhi's corner

Edited 1 time(s). Last edit at 02/01/2017 04:04PM by bodhi.
Re: nsa325 copy button event
February 02, 2017 08:24AM
Hey Bodhi,
I even read something about esekeyd when flying though the threads, but still decided to use the more complicated way...
Half-asperger-mind ;)

Once again thank You, installing and configuring took 5 minutes, everything works now as expected!


Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.