LIRC on Mint 19.1 / Ubuntu 18.04
This was originally published in 2019 for Ubuntu 18.04. I no longer run LIRC on a general-purpose Linux distro, in favour of CoreELEC on dedicated hardware, so I am unsure whether these steps are still required on current releases. This is provided here for historic reference.
The Problem
I recently updated one of my systems from Mint 17 to Mint 19.1. Mint 17 is based on Ubuntu 14.04 and Mint 19 is Ubuntu 18.04. I run MythTV front-end and Kodi on the system, controlled with a Windows Media Center IR remote using LIRC.
Out of the box, the MCE worked with minimal functionality (cursor keys only), and the LIRC configuration utility is broken.
I tried a few things, including trying to use the built-in support for the USB MCE remotes (with a combination of creating a custom keymap file then running ir-keytable -c -w /etc/rc_keymaps/rc6_mce
), and although that worked fine for Kodi, I really wanted LIRC to be working again so that I could use irexec to launch using the WMC Green Button, as well as being able to use my MythTV mapping (even though most of my PVR needs are catered for by Kodi now).
The Solution
LIRC Configuration
Out of the box, LIRC 0.10 on Ubuntu 18.04 uses devinput. This probably works for simple needs to get an out of the box configuration that works, but it's better to switch to native device support to avoid some annoying quirks of devinput mode (in particular, repeated/bouncing keys). The config tools for LIRC appear to be broken in Ubuntu 18.04, but for MCE remotes, this doesn't matter because the configuration can be done quite easily with a text editor.
Change this in /etc/lirc/lirc_options.conf
by changing the driver line from devinput
to default
. Also specify the specific device. For example:
[lircd]
nodaemon = False
driver = default
device = /dev/lirc0
output = /var/run/lirc/lircd
pidfile = /var/run/lirc/lircd.pid
plugindir = /usr/lib/x86_64-linux-gnu/lirc/plugins
permission = 666
allow-simulate = No
repeat-max = 600
[lircmd]
uinput = False
nodaemon = False
Pointing Kodi to the correct location
Note that Kodi looks for LIRC at /dev/lircd, not /var/run/lirc/lircd as default in Ubuntu 18.04, but if you change that in lirc_options.conf then Kodi will work but none of the other tools such as irw or irexec will. Therefore, it's easiest to simply create a symlink:
ln -s /var/run/lirc/lircd /dev/lircd
This will only survive until the system is rebooted, so you might want to automate the creation of this symlink using cron.
Create the MCE USB mapping file
Create a config file for mceusb at /etc/lirc/lircd.conf.d/mceusb.conf
with the following contents:
#
# brand: HP/Philips/Microsoft/Other
# model no. of remote control: Media Center Edition remote
# devices being controlled by this remote: HP Slimline S3100y and a
# myriad of devices with Media Center Edition receivers
#
# RC-6 config file
#
# source: http://home.hccnet.nl/m.majoor/projects_remote_control.htm
# http://home.hccnet.nl/m.majoor/pronto.pdf
#
# used by: Philips
#
#########
#
# Philips Media Center Edition remote control
# For use with the USB MCE ir receiver
#
# Dan Conti dconti|acm.wwu.edu
#
# Updated with codes for MCE 2005 Remote additional buttons
# *, #, Teletext, Red, Green, Yellow & Blue Buttons
# Note: TV power button transmits no code until programmed.
# Updated 12th September 2005
# Graham Auld - mce|graham.auld.me.uk
#
# Radio, Print, RecTV are only available on the HP Media Center remote control
#
#
# Updated with codes for MCE 2007 Remote additional buttons
# Visualization, Aspect, SlideShow, Eject
# Note:
# Renamed some buttons: DVD->DVDMenu, More->MoreInfo, Star->Asterisk, Hash->Pound
# Note:
# Blue, Yellow, Green, Red, and Teletext buttons do not exist on the HP remote
begin remote
name mceusb
bits 16
flags RC6|CONST_LENGTH
eps 30
aeps 100
header 2667 889
one 444 444
zero 444 444
pre_data_bits 21
pre_data 0x37FF0
gap 105000
toggle_bit 22
rc6_mask 0x100000000
begin codes
#seen on HP Pavilion dv3t remote --Tim Mann, 3 Nov 2009
Media 0x00007b7f
PlayPause 0x00007b91
#unused by HP remote
KEY_BLUE 0x00007ba1
KEY_YELLOW 0x00007ba2
KEY_GREEN 0x00007ba3
KEY_RED 0x00007ba4
Teletext 0x00007ba5
#ba6 - bae unused
BA6 0x00007ba6
BA7 0x00007ba7
BA8 0x00007ba8
BA9 0x00007ba9
BAA 0x00007baa
BAB 0x00007bab
BAC 0x00007bac
BAD 0x00007bad
BAE 0x00007bae
KEY_RADIO 0x00007baf
Print 0x00007bb1
#bb2 - bb4 unused
BB2 0x00007bb2
BB3 0x00007bb3
BB4 0x00007bb4
KEY_VIDEO 0x00007bb5
Pictures 0x00007bb6
RecTV 0x00007bb7
KEY_AUDIO 0x00007bb8
KEY_TV 0x00007bb9
#bba - bbf unused
BBA 0x00007bba
BBB 0x00007bbb
BBC 0x00007bbc
BBD 0x00007bbd
BBE 0x00007bbe
BBF 0x00007bbf
#bc1 - bca unused
BC1 0x00007bc1
BC2 0x00007bc2
BC3 0x00007bc3
BC4 0x00007bc4
BC5 0x00007bc5
BC6 0x00007bc6
BC7 0x00007bc7
BC8 0x00007bc8
BC9 0x00007bc9
BCA 0x00007bca
KEY_EJECTCD 0x00007bcb
SlideShow 0x00007bcc
Visualization 0x00007bcd
#bce - bcf unused
BCE 0x00007bce
BCF 0x00007bcf
#bd1 - bd7 unused
BD1 0x00007bd1
BD2 0x00007bd2
BD3 0x00007bd3
BD4 0x00007bd4
BD5 0x00007bd5
BD6 0x00007bd6
BD7 0x00007bd7
Aspect 0x00007bd8
Guide 0x00007bd9
LiveTV 0x00007bda
KEY_DVD 0x00007bdb
#NoGap
KEY_BACK 0x00007bdc
KEY_OK 0x00007bdd
KEY_RIGHT 0x00007bde
KEY_LEFT 0x00007bdf
KEY_DOWN 0x00007be0
KEY_UP 0x00007be1
#NoGap
Star 0x00007be2
Hash 0x00007be3
#NoGap
KEY_AGAIN 0x00007be4
KEY_NEXT 0x00007be5
KEY_STOP 0x00007be6
KEY_PAUSE 0x00007be7
KEY_RECORD 0x00007be8
KEY_PLAY 0x00007be9
KEY_REWIND 0x00007bea
KEY_FORWARD 0x00007beb
#NoGap
KEY_CHANNELDOWN 0x00007bec
KEY_CHANNELUP 0x00007bed
KEY_VOLUMEDOWN 0x00007bee
KEY_VOLUMEUP 0x00007bef
#NoGap
More 0x00007bf0
KEY_MUTE 0x00007bf1
KEY_HOME 0x00007bf2
KEY_POWER 0x00007bf3
#NoGap
KEY_ENTER 0x00007bf4
KEY_CLEAR 0x00007bf5
#NoGap
KEY_9 0x00007bf6
KEY_8 0x00007bf7
KEY_7 0x00007bf8
KEY_6 0x00007bf9
KEY_5 0x00007bfa
KEY_4 0x00007bfb
KEY_3 0x00007bfc
KEY_2 0x00007bfd
KEY_1 0x00007bfe
KEY_0 0x00007bff
end codes
end remote
#
# this config file was automatically generated
# using lirc-0.8.4a(default) on Mon Feb 23 23:55:04 2009
#
# contributed by
#
# brand: Hauppauge
# model no. of remote control:
# devices being controlled by this remote: PVR-150 Remote (MCE kit)
# SMK dongle 0609:031d
#
begin remote
name mceusb_hauppauge
bits 13
flags RC6|CONST_LENGTH
eps 30
aeps 100
header 2674 870
one 455 427
zero 455 427
pre_data_bits 24
pre_data 0x1BFF82
gap 106288
min_repeat 1
toggle_bit_mask 0x8000
rc6_mask 0x100000000
begin codes
TV 0x1BB9
Music 0x1BB8
Pictures 0x1BB6
Videos 0x1BB5
Power 0x1BF3
Stop 0x1BE6
Record 0x1BE8
Pause 0x1BE7
Play 0x1BE9
Rewind 0x1BEA
Foward 0x1BEB
Replay 0x1BE4
Skip 0x1BE5
Back 0x1BDC
More 0x1BF0
Up 0x1BE1
Left 0x1BDF
Right 0x1BDE
OK 0x1BDD
Down 0x1BE0
VolUp 0x1BEF
VolDown 0x1BEE
Home 0x1BF2
ChanDown 0x1BED
ChanUp 0x1BEC
Mute 0x1BF1
RecTV 0x1BB7
Guide 0x1BD9
LiveTV 0x1BDA
DVD 0x1BDB
One 0x1BFE
Two 0x1BFD
Three 0x1BFC
Four 0x1BFB
Five 0x1BFA
Six 0x1BF9
Seven 0x1BF8
Eight 0x1BF7
Nine 0x1BF6
Star 0x1BE2
Zero 0x1BFF
Hash 0x1BE3
Clear 0x1BF5
Enter 0x1BF4
end codes
end remote
#
# this config file was automatically generated
# using lirc-0.8.4a(default) on Tue Mar 10 19:27:09 2009
#
# contributed by
#
# brand: SIIG Vista MCE remote
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name vista_mce
bits 16
flags RC6
eps 30
aeps 100
header 2654 889
one 427 427
zero 427 427
pre_data_bits 21
pre_data 0x37FF0
gap 69850
toggle_bit_mask 0x8000
rc6_mask 0x100000000
begin codes
Power 0xEBF3
Pictures 0x6BB6
Radio 0xEBAF
Videos 0x6BB5
Music 0xEBB8
Rec 0x6BE8
Pause 0xEBE7
Stop 0x6BE6
Skipback 0xEBE4
Play 0x6BE9
Skipfwd 0xEBE5
Rwd 0x6BEA
Fwd 0xEBEB
Start 0x6BF2
Back 0xEBDC
More 0x6BF0
Volup 0xEBEF
Voldown 0x6BEE
Chup 0xEBED
Chdown 0x6BEC
Up 0xEBE1
Down 0x6BE0
Left 0xEBDF
Right 0x6BDE
Mute 0xEBF1
Rectv 0x6BB7
Guide 0xEBD9
Livetv 0x6BDA
Dvdmenu 0xEBDB
1 0x6BFE
2 0xEBFD
3 0x6BFC
4 0xEBFB
5 0x6BFA
6 0xEBF9
7 0x6BF8
8 0xEBF7
9 0x6BF6
* 0xEBE2
0 0x6BFF
# 0xEBE3
Clear 0x6BF5
Enter 0xEBF4
end codes
end remote
Testing if the remote works
Restart LIRCd using systemctl restart lircd
and then check with systemctl status lircd
and you should see output such as this:
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Notice: Current driver: default
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Notice: Driver API version: 3
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Notice: Driver version: 0.10.0
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Notice: Driver info: See file:///usr/share/doc/lirc/plugindocs/default.
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Info: lircd: Opening log, level: Info
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Warning: Running as root
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Info: Using remote: mceusb.
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Info: Using remote: mceusb_hauppauge.
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Info: Using remote: vista_mce.
Dec 23 15:19:29 server1 lircd-0.10.0[22534]: Notice: lircd(default) ready, using /var/run/lirc/lircd
At this point you should be able to use irw to test the remote using LIRC. Pressing buttons on the remote should result in output whilst irw is running.
000000037ff07bf2 00 KEY_HOME mceusb
000000037ff07bdf 00 KEY_LEFT mceusb
000000037ff07be0 00 KEY_DOWN mceusb
000000037ff07bde 00 KEY_RIGHT mceusb
000000037ff07bdd 00 KEY_OK mceusb
Note how the output from irw now includes "mceusb" instead of "devinput" and the key names match what they should be for the MCE remote.
Making Kodi work with LIRC
Finally, I created the .lircrc file in my home directory. I'm not going to reproduce the entire contents here, and this is standard LIRC stuff at this point, so here's a snippet (note that I call Kodi via a bash script in order to handle the case where it's already running - included below, but you can call /usr/bin/kodi directly if that doesn't bother you):
# Launch Kodi
begin
prog = irexec
button = KEY_HOME
#config = /usr/bin/kodi &
config = /home/kodi/startkodi.sh &
end
# MythTV-specific mapping
begin
prog = mythtv
button = LiveTV
config = t
end
begin
prog = mythtv
button = RecTV
config = w
end
begin
prog = mythtv
button = Media
config = M
end
....etc
The Kodi launch script (to avoid launching a duplicate instance, as well as forcing exposing ALSA interfaces for audio) is as follows:
#!/bin/bash
if pidof -x "kodi.bin" >/dev/null; then
exit
else
AE_SINK=ALSA kodi &
fi
Conclusion
With all of this complete, the behaviour of the remote is now as follows:
- Pressing the "green button" on the remote will launch Kodi
- Pressing the "green button" when Kodi is already running, will not launch a second instance, but instead, the designation of the green button in Kodi's own mapping is used (i.e. return to home page, or show menu during playback)
- Pressing any of the other buttons on the MCE remote will work inside Kodi using their pre-defined configuration, or you can optionally override them with Lircmap.xml.
This information was correct as of December 2018, using Linux Mint 19.1, Kodi 17.6 and LIRC 0.10.