Linux shell: poll the keyboard button's state -
I have a script that is executed from time to time in the background by pressing the shift key But I want to stop its execution.
This keyboard is voting to the Shift button position, and if it is pressed - close the script immediately.
Any thoughts? X server is allowed to use: I think it would be helpful.
UPD: I am currently using this stupid hack:
[$ (Sh -c 'cat / dev / input Kill / by-id / usb- * kbd and sleep 0.5; $$! 2> / dev / null '| wc -c) -gt 1] & amp; Amp; Exit
The script only detects the current keyboard events but does not separate them. 0.5sec kbd-events have clock duration. Not very good, but still works :)
First of all, you key / bottom You can monitor the events, but as far as I know, there is no way to say that the key currently is pressed if you are ok with that ... then ... < / P>
This means that listening to the main event has to be run in another thread. The shell script will have to create a program in the background that listens for major events and sends a signal to the parent script on the keyboard. You can use gracefully to answer the signal coming out of the signal.
Check out. This can give you a good start.
You can also be able to help you can.
Comments
Post a Comment