Make LIRC work in Ubuntu 18.04, 20.04, or 22.04, so that you can use your infrared remote in Kodi

remote.png

(This article has been slightly edited as of August 2020, to add additional comments regarding Ubuntu 20.04, and in August 2022 to add comments regarding Ubuntu 22.04)

If you are a Kodi user and have recently tried to upgrade your system to Ubuntu 18.04 (or newer), and then tried to install and use LIRC to make your infrared remote control work the way it should, you may have discovered that it doesn’t work. For one thing, you don’t get the configuration menu during the install process, so you can’t select your make and model of remote. Even the old standby of using sudo dpkg-reconfigure lirc to bring up the configuration menu doesn’t work anymore.

Chances are you searched the web for an answer, but perhaps you never found anything that would make your remote work as smoothly as it used to in past versions of Ubuntu. Even if you got the remote to work in Kodi, you probably got double button presses or a lack of response to button presses on some buttons at random times, and maybe certain buttons would not work at all. We have heard of Kodi users giving up and going back to Ubuntu 16.04 because of this issue!

It turns out that the issue may not be with Ubuntu OR Kodi.  It appears the problem is that the Ubuntu 18.04 and later repositories contain a newer version of LIRC, that just doesn’t work properly.  We found that going back to an old version, specifically LIRC 0.9.0, is the answer – install that, and you do get a version of LIRC that works in Ubuntu 18.04 and that makes your remote work smooth as silk in Kodi.  Well, at least it did for ours, which is a standard Windows MCE compatible remote similar to the one pictured above.

So how do you do that?  Well, as the title of this blog implies, we are two “sort of” tech guys, and one thing we are not is Linux experts.  So, we took an approach that is relatively easy and that works, even if it may not be the “most correct” way to do it.  Here’s the procedure we used:

First, remove any existing installs of ir-keytable and/or lirc – from Linux command line do:

sudo apt purge ir-keytable lirc

Also, if you have added any other software in an attempt to get the remote to work, you probably should remove that as well.

Next, we’re going to temporarily edit /etc/apt/sources.list – we will use nano, but feel free to use vi or vim if that’s your thing:

sudo nano /etc/apt/sources.list

Add this line at the bottom of the /etc/apt/sources.list file:

deb http://ca.archive.ubuntu.com/ubuntu/ xenial universe

Note that because xenial is no longer a supported version, you may have to add [trusted=yes] as shown below before it will work:

deb [trusted=yes] http://ca.archive.ubuntu.com/ubuntu/ xenial universe

Use Ctrl-X to exit nano; be sure to save the file (unless you made a mistake, then just exit without saving and start over).

Then, from the Linux command line:

sudo apt update
sudo apt install lirc/xenial

You should see it install lirc and a few dependencies.  Somewhere in the process you should see “Setting up lirc (0.9.0-0ubuntu6) …” and also you should get the configuration screen, from which you can pick the type of infrared remote you use (such as “Windows Media Center Transceivers/Remotes (all)”, which is down near the bottom of the list).

lirc configuration screenClick on the image to enlarge

Note that if you are using a more recent version of Ubuntu such as 20.04 you may see an error message during this process that looks similar to this:

ls: cannot access ‘/lib/modules/5.4.0-42-generic/kernel/drivers/staging/media/lirc’: No such file or directory

In Ubuntu 22.04 you may also get an error or warning because you are installing such an old version of LIRC.

But, that does not necessarily mean the installation has failed. If you get to the configuration screen, you are probably okay.

After that is finished, do this so Ubuntu won’t try to upgrade lirc to the newer bad version:

sudo apt-mark hold lirc

Now that lirc is installed, you need to go back and remove the line you just added to /etc/apt/sources.list:

sudo nano /etc/apt/sources.list

Scroll down to the bottom of the file and put the cursor at the start of this line and press Ctrl-K to delete it:

deb http://ca.archive.ubuntu.com/ubuntu/ xenial universe

As before use Ctrl-X to exit nano, and be sure to save the file.

Now from the command line you should immediately do this so that your system doesn’t inadvertently try to get any other packages from the xenial universe repository:

sudo apt update

And that’s it!  What we have done here is to temporarily enable the Ubuntu 16.04 (xenial) universe repository, where a copy of lirc 0.9.0 is available, and then we installed it using the apt command.

If lirc does not appear to be working, first try rebooting the system, and if that doesn’t work make sure that your system doesn’t have more than one infrared receiver. For example, if you are using a USB connected IR receiver, and your computer also has an IR receiver built in or even just has the circuitry for such a receiver, that can stop lirc from working because it may be trying to get input from the wrong device. You may need to disable the built in one in the system’s BIOS settings, or you may need to blacklist it in the /etc/modprobe.d/blacklist.conf file.  We had to add the line

blacklist ite_cir

to the /etc/modprobe.d/blacklist.conf file on one system to make lirc work correctly.  You may be able to find out if there is more than one IR receiver by running this command:

cat /proc/bus/input/devices

Note that this will show more than just the IR receivers, and may or may not show the driver name to blacklist.  If you do have a built in IR receiver that you can’t disable in the BIOS, there’s a good chance that blacklisting the ite_cir driver will work, but if not you may have to do a little online searching to find the correct driver name to use in the blacklist line.

If you plan to use lirc to control anything other than Kodi that requires the use of a .lircrc file in your home directory, don’t forget to create that file (or move it from a backup of your previous installation if you are upgrading, along with any scripts that are referenced within .lircrc) and also don’t forget that you need to run irexec -d before the .lircrc file will be recognized. If you want irexec to launch when Ubuntu is booted up, you can go to the Startup Applications app and then click the Add button, and fill in the three text fields like this:

Name: irexec
Command: irexec -d
Comment: (whatever you like, or leave blank)

We do realize that there may be alternative ways to install this particular version of lirc, such as downloading the lirc package from the xenial repository (the amd64 version is here) and then installing it using dpkg, but we’d be a little concerned that doing it that way either might not bring in the necessary dependencies, or might not show the configuration menu.  But, feel free to try doing it that way if you’re much more conversant with Linux than we are.

We hope this helps others who have struggled to get their infrared remote working with Kodi in Ubuntu 18.04! We’ve also now tested this with one installation of Ubuntu 20.04, and then again with one installation of Ubuntu 22.04, and at least as of August 2022 it worked for us. We hope it works for you as well.

Also, every so often someone suggests that there are “better” ways to get the infrared remote to work now. Typically these “better” ways involve following a much longer set of instructions, and when you are through they will only allow your remote to control Kodi and nothing else. You can’t even start Kodi from the desktop using such “improved” methods, let alone use your remote to launch or control other software, all of which is possible when using the old version of lirc. The two biggest advantages of using the old version of lirc are that it “just works” without a lot of configuration, and that you can use your remote for other purposes rather than just controlling Kodi if you create a proper .lircrc file. So if you are thinking about leaving a comment suggesting the use of different software to enable your remote control, please keep the above in mind and don’t suggest something that will only work within Kodi and nowhere else!

If you liked this article, you may also want to read our followup article: Extending the remote control capabilities of LIRC.