# ir remote with arch linux and lirc

I have an HTPC running Kodi (Formerly XMBC) and I’ve been trying to get an old IR remote working with it. I’ve got Kore on android currently controlling Kodi, but I wanted to see if I could get an old Microsoft Media Center PC’s IR receiver to work.

I used one of these receivers:

I couldn’t find the actual MCE remote that went with the receiver, so I used this Sony DVD player remote, but any remote should work.

This took entirely too long for me to figure out. The last three days have been spent with the remote working one minute and then not for seemingly no reason and then it seemed to remap the buttons out of nowhere. It was a serious pain in the ass, but it seems to be working correctly now.

Here is what I did:

First, install lirc. I am running arch, so pacman -S lirc.

Edit /etc/lirc/lircd.conf to:

 1   include "usr/share/lirc/configs/devinput.conf" 

Next edit your keymap. I copied /lib/udev/rc_keymaps/rc6_mce to /etc/rc_keymaps/rc6_mce. You can run ir-keytable -t -p SONY,RC6 -w /etc/rc_keymaps/rc6_mce to figure out what codes your remote is using for each button. You can then edit /etc/rc_keymaps/rc6_mce with the correct codes that your remote is using.

Here is my rc6_mce:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21   1 # table rc6_mce, type: RC6 2 3 0x1a490b KEY_ENTER 4 0x1a491b KEY_MEDIA 5 0x1a4964 KEY_MUTE 6 0x10012 KEY_VOLUMEUP 7 0x10013 KEY_VOLUMEDOWN 8 0x1a4923 KEY_FASTFORWARD 9 0x1a4922 KEY_REWIND 10 0x1a4932 KEY_PLAY 11 0x1a4939 KEY_PAUSE 12 0x1a4938 KEY_STOP 13 0x1a4931 KEY_NEXT 14 0x1a4930 KEY_PREVIOUS 15 0x1a4979 KEY_UP 16 0x1a497a KEY_DOWN 17 0x1a497b KEY_LEFT 18 0x1a497c KEY_RIGHT 19 0x1a490b KEY_OK 20 0x1a490e KEY_EXIT 21 0x1a4939 KEY_PLAYPAUSE 

Then edit the lircd unit (systemctl edit --full lircd.service) to:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24   1 [Unit] 2 Description=LIRC Daemon 3 After=network.target 4 5 [Service] 6 Type=forking 7 8 9 PIDFile=/run/lirc/lircd.pid 10 ExecStartPre=/bin/mkdir -p /run/lirc 11 ExecStartPre=/bin/rm -f /dev/lircd 12 ExecStartPre=/bin/rm -f /run/lirc/lircd 13 ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd 14 15 ExecStartPre=/usr/bin/ir-keytable -c 16 ExecStartPre=/usr/bin/ir-keytable -p SONY,RC6 -w /etc/rc_keymaps/rc6_mce 17 18 ExecStart=/usr/sbin/lircd 19 ExecStopPost=/bin/rm -f /dev/lircd 20 ExecStopPost=/bin/rm -fR /run/lirc 21 22 23 [Install] 24 WantedBy=multi-user.target 

You should be able to start the lircd service with no errors. The arrow keys on the remote should work just like the arrow keys on the keyboard. Hitting the up button should scroll up through the history on the command line.

I am using this remote with Kodi standalone, so I need to add a Lircmap.xml to /var/lib/kodi/.kodi/userdata/Lircmap.xml

  1 2 3 4 5 6 7 8 9 10 11 12 13   1 2 3 KEY_UP 4 KEY_DOWN 5 KEY_LEFT 6 KEY_RIGHT 7 KEY_PLAY 8 KEY_PAUSE 9 KEY_STOP 10 KEY_ENTER 11 KEY_BACK 12 13 

This will map the remote buttons to Kodi actions.

You should be able to reboot and everything should work.