# lircd works when run from command line, not when run from init.d/service

I'm configuring a system for use as a media centre, running Mythbuntu 12.04. Everything is working, short of the remote. I've configured my remote, and it I start lirc from the command line, it works fine. If I run it from the init script service lirc start it doesn't work. (For this purpose, work means to have irw show an output). In both cases I'm using exactly the same command (in fact, for running it from the command line, I'm just copying the command that is present in ps -ef). Both cases have lirc running as root (at least that's what ps -ef tells me). Both cases produce exactly the same info in syslog.

Command to start lirc:

sudo /usr/sbin/lircd --output=/var/run/lirc/lircd --driver=devinput --device=/dev/input/irremote


syslog output (start lirc, start irw, stop irw, kill lirc):

Aug 13 22:06:05 Myth-FJ lircd-0.9.0[4917]: lircd(devinput) ready, using /var/run/lirc/lircd
Aug 13 22:06:05 Myth-FJ lircd-0.9.0[4917]: accepted new client on /var/run/lirc/lircd
Aug 13 22:06:05 Myth-FJ lircd-0.9.0[4917]: initializing '/dev/input/irremote'
Aug 13 22:06:28 Myth-FJ lircd-0.9.0[4917]: accepted new client on /var/run/lirc/lircd
Aug 13 22:06:35 Myth-FJ lircd-0.9.0[4917]: removed client
Aug 13 22:06:42 Myth-FJ lircd-0.9.0[4917]: caught signal
Aug 13 22:06:42 Myth-FJ lircd-0.9.0[4917]: closing '/dev/input/irremote'


I'm completely stumped.

-
Do you use sudo for service lirc start? –  Braiam Aug 13 '13 at 12:17
@Braiam: Yes; the service starts and runs correctly –  askvictor Aug 13 '13 at 12:18
so, you forgot to add sudo before service? –  Braiam Aug 13 '13 at 12:35
@Braiam: no; I start the service with sudo. If I didn't, it wouldn't start, as a normal user would lack the permissions. Besides which, I stated in my post that lirc is running as root in both cases. EDIT: to clarify, when I said "the service starts and runs correctly", it starts, and doesn't show any errors, but doesn't produce any useful output to irw –  askvictor Aug 13 '13 at 12:50

I had the same symptoms, lirc would not work when run as a service, but would work as a command. Note that in my case some of the keys worked, but only when lirc was not running (neither as a service nor a command).

The problem was that evdev (an input driver for Xorg) was picking up the remote as a keyboard input device. Getting evdev to ignore the remote solved the problem for me. I guess that the lirc service start script got hung up by the fact that evdev had a handle on the remote, somehow.

The following is from the last post in that thread. Note: TBS6981 is the satellite tuner which I was using as my remote receiver.

The problem was caused by evdev (an input driver for Xorg) which was picking up the remote as a keyboard input device. This could be seen from my Xorg logs (/var/log/Xorg...), see below. Most of the buttons don't work by default because they don't naturally map to keyboard buttons, e.g. your keyboard doesn't have an EPG key, but it does have numbers and direction keys.

There are basically two solutions

1. Configure evdev to ignore the IR input and use lirc OR
2. Remap the remote buttons to keyboard keys, as discussed in this post, and don't use lirc

evdev can be configured to ignore the TBS6981 as a keyboard by adding the following to the end of /usr/share/X11/xorg.conf.d/10-evdev.conf -

Section "InputClass"
Identifier "cx23885 IR (TurboSight TBS 6981)"
MatchProduct "cx23885 IR (TurboSight TBS 6981)"
MatchIsKeyboard "on"
Option "Ignore"
EndSection


Note that MatchProduct above matches the identifier found in Xorg.0.log.

This is an extract from Xorg.0.log showing evdev picking the remote input, these lines do not appear if evdev is correctly configured to ignore the remote as a keyboard:

[    21.486] (II) config/udev: Adding input device cx23885 IR (TurboSight TBS 6981) (/dev/input/event3)
[    21.486] (**) cx23885 IR (TurboSight TBS 6981): Applying InputClass "evdev keyboard catchall"
[    21.486] (II) Using input driver 'evdev' for 'cx23885 IR (TurboSight TBS 6981)'