Welcome to the Linux Foundation Forum!

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:

#!/bin/bash
while true
do
read -n 1 ir_code

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

done


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

Categories

Upcoming Training