A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

April 30, 2015

Reading keystrokes when running as a service

Newbe here so be gentle.
I want to capture keystrokes send out by the FLIRC dongle and toggle some GPIO pins accordingly. I made a script file which works fine when I run it from the command line. But it doesn't work when it runs as a service. I think it doesn't receive any keystrokes at all. Basically, what I've done is this:

while true
read -n 1 ir_code

case $ir_code in
echo "... inschakelen"
echo 1 > /sys/class/gpio/gpio200/value
sleep 2
echo 1 > /sys/class/gpio/gpio91/value
echo "Uitschakelen ..."
echo 0 > /sys/class/gpio/gpio91/value
sleep 2
echo 0 > /sys/class/gpio/gpio200/value


How can I make this work when running as a service?

Click Here!