HOW-TO:Set up LIRC
|Remotes||LIRC||HOW-TO:Set up LIRC|
|This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.|
This guide explains how to set up Kodi to understand a universal remote's commands (so not the standard MCE remotes that work out of the box). You obviously need some hardware device for this that reads infrared commands. I'm using a cheap (+- 10 euro) device called the IRMan. You can find a list of supported devices here.
1 Download and install Lirc
First you have to download and install Lirc. If you're using Ubuntu or Debian you can just type apt-get install lirc. If you don't have a lirc package in you distribution or (in my case) a buggy version, it's pretty easy to compile lirc from source:
[email protected]:~$ wget http://prdownloads.sourceforge.net/lirc/lirc-0.9.4b.tar.bz2 [email protected]:~$ tar -jxf lirc-0.9.4b.tar.bz2 [email protected]:~$ cd lirc-0.9.4b [email protected]:~/lirc-0.9.4b$ aclocal && autoheader && autoconf [email protected]:~/lirc-0.9.4b$ ./configure --with-x --with-driver=irman (or whatever remote you are using, check ./configure --help for supported ones - for homebrew serial IR use --driver=serial) [email protected]:~/lirc-0.9.4b$ make && sudo make install
Next comes the interesting part.
2 Configure Lirc to understand your remote's commands
You have downloaded and installed Lirc and are now ready to set it up. First, check if your IR receiver is already preconfigured. Ubuntu stores the configuration files in '/usr/share/lirc/remotes but you can also find them in the source tree in the remotes directory. If you can find you remote, copy the config file to /etc/lirc/lircd.conf and open the file with a text editor. Delete the lines between begin codes and end codes.
2.1 Learning Commands
Now we're going to learn commands. Fire up irrecord with the following command:
[email protected]:~$ sudo -s ## you have to be root for this part [sudo] password for user: [email protected]:~# cd /etc/lirc [email protected]:/etc/lirc# irrecord --driver=irman --device=/dev/ttyS0 MyRemote ## use the driver that you chose in the previous part. /dev/ttyS0 = first com port
You'll get a wall of text and are asked to press enter. Next you'll see a prompt.
Hold down an arbitrary button.
Just hold down any button on your remote until the next prompt.
Found gap length: 215947 Now enter the names for the buttons.
Now you have to learn all buttons. Enter a name, press enter, hold down the button you are learning and repeat. When you're done, press enter. Press one button on your remote as fast as possible but DO NOT hold it down.
2.2 Testing the new lirc configuration
Next we're going to test the config file we just created. Start lirc with the following command:
[email protected]:/etc/lirc# lircd --driver=irman --device=/dev/ttyS0 /etc/lirc/MyRemote
You can test your config by starting irw:
[email protected]:/etc/lirc# irw
Press the buttons on your remote you just learned and see if they match. Press ctrl+c to quit irw. If there's a problem, stop lirc with
[email protected]:/etc/lirc# killall lircd
delete the file we just created
[email protected]:/etc/lirc# rm -f MyRemote
and repeat the whole learning process back from the top. If it still doesn't work, have a look at this site or ask on the forums.
2.3 Make the changes to lirc
If irw gave the right output, stop lirc with
[email protected]:/etc/lirc# killall lircd
and move the file we created to lircd.conf
[email protected]:/etc/lirc# mv MyRemote lircd.conf
Finally start up lirc with
[email protected]:/etc/lirc# /etc/init.d/lircd start
You can now leave your root shell.
3 Configure Kodi to understand Lirc's commands
So now that you configured lirc and irw gives the expected output, it's time to let lirc talk to Kodi. Start your text editor and open the file named Lircmap.xml, which is usually located in $home$/.kodi/userdata/ and the generic is on /usr/share/Kodi/system/. There are some remotes in there by default. Copy the part between
<remote device="mceusb"> ... </remote>
and paste it in the file. Change the new mceusb to MyRemote (or whatever name you picked for your remote in the lirc configuration) and change the values of the tags to the names of the buttons. If you forgot them, they are in /etc/lirc/lircd.conf.
The Lircmap.xml configuration is explained in more detail in this forum post
4 It works :)
remember order to use lirc on Kodi (generic for ubuntu) first install modules then compiling lirc then setting remote
5 Changes in Linux IR
With kernel 2.6.35 some changes began to be made in the way Linux handles infrared remotes. What used to be a job just for LIRC is now partly done by the Linux kernel. Some distributions 'backport' changes to the kernel, so even though your kernel is older than 2.6.35 it might affect you.
The drivers for several remotes have been moved into the kernel and this means that many of them should 'Just Work' out of the box. Unfortunately LIRC, the LIRC configuration tools, the distribution setup scripts for LIRC and most of the documentation available has not yet (as of February 2011) been updated to reflect these changes. If you are experiencing problems, your remotedriver may have been moved to the kernel. In this case, try to setup LIRC with 'devinput' as the driver (and something like /dev/input/event3 as the device). Further reading: Getting the key symbols using linux input layer Linux input layer driver