You are not logged in.

#1 2015-04-28 07:21:20

phibon
Member
Registered: 2015-04-28
Posts: 1

How to capture keystrokes from LIRC dongle

Hello,

Newbe here so be gentle.

I want to capture keystrokes send out by the LIRC dongle. I made a script file which runs correctly when I run it from the command line. But it doesn't seem to work when ir runs as a service.
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

Is there a reason why this won't work as a service?

Offline

#2 2015-08-15 02:42:15

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 240

Re: How to capture keystrokes from LIRC dongle

The reason is that `read' command reads symbols from standard input. When you start the script from the command line the standard input is taken from evdev subsystem. When you start the script as a service the standard input is likely redirected to /dev/null.
Probably you need to use lirc command line utilites such as irw to handle IR data.

Last edited by dimich (2015-08-15 02:42:37)

Online

Board footer

Powered by FluxBB