LIRC/Quick start guide
Step-by-step LIRC setup guide for USB (MCE [Media Center Edition]) IR receiver with universal remote control.
This is a quick-start guide only. Please refer to man pages of the commands and files used and online documentation for in-depth help.
Prerequisites
- Get a USB IR receiver, preferably an MCE model which is almost always supported out-of-the-box.
- Re-purpose an old universal remote control you have lying around the house.
Setup
- Connect the USB IR receiver.
- Ensure there are fully charged batteries in your remote control.
- Get some kind of output/response from the remote using
mode2
:# mode2
Point the remote control at the IR receiver and press some buttons. This will attempt to autodetect the correct input device using the default "devinput" driver. However, this might not work without manual configuration of protocols. - If no button presses are detected for most keys, change IR protocols. If you get no response to the remote control buttons you want to use, you likely need to enable different protocols:
# ir-keytable -p <protocol> -p <protocol> ...
Look at the output ofir-keytable
(as well ascat /sys/class/rc/rc0/protocols
). When you have problems, runir-keytable -p all
as root. - If no button presses are detected for most keys, try different universal remote control device modes. You may also need to try different universal remote control device modes (TV, DVD, Audio, etc., buttons) in order to detect button presses when you are getting started. (You could possibly reprogram the universal remote's modes, but that would likely be a long trial-and-error process to find a setting that works.)
- After reconfiguring IR protocols and remote control device mode, retest:
# mode2
Point the remote control at the IR receiver and press some buttons. If button presses for most keys are not detected repeat the prior two steps until they are (or just runir-keytable -p all
as root). - If you have narrowed down what protocols you need to support for your remote control, set them:
# ir-keytable -p sony -p rc-5
Otherwise, you can just use all protocols:# ir-keytable -p all
- Determine the correct device for your IR receiver. Use either the default "devinput" driver or the older "default" driver:
$ mode2 --driver devinput --list-devices $ mode2 --driver default --list-devices $ ir-keytable
- Use the device found for your USB IR receiver, e.g.,
/dev/input/event11
:# mode2 --driver devinput --device /dev/input/event11
or just try:# mode2 --driver devinput --device auto
See if button presses are detected. - If required, edit
/etc/lirc/lirc_options.conf
, e.g., if you are using the driver "default" instead of "devinput". - Test your remote to see if scancodes are printed:
# ir-keytable -t
See if button presses are detected. - Use a drop-in file:
/etc/systemd/system/lircd.service.d/override.conf
. At the[Service]
section add the following line:ExecStartPost=/usr/bin/ir-keytable -p protocol -p protocol
where each protocol string is replaced by the protocol(s) you need (or just use/usr/bin/ir-keytable -p all
). - Start the lirc daemon,
lircd.service
, so you can record keypresses in order to write an lircd configuration file for your remote control. - Use irrecord to record keypress scancodes. Run:
# irrecord
to save/record the keystrokes to be used for your application. Followirrecord
's instructions. - Install the recorded lircd configuration file:
# mv device_name.lircd.conf /etc/lirc/lircd.conf.d/
# chown root:root /etc/lirc/lircd.conf.d/device_name.lircd.conf - Move
devinput.lircd.conf
todevinput.lircd.dist
to disable it, because you are not using an IR keyboard and/or mouse, just the IR receiver:# mv /etc/lirc/lircd.conf.d/devinput.lircd.conf /etc/lirc/lircd.conf.d/devinput.lircd.dist
- Restart
lircd.service
so you use the newly created lircd configuration file. - Test to make sure the keys you recorded are correctly detected, that is, the correct key symbol is output for each button you press:
$ irw
See if the correct key symbols are reported, and if repeated signals are properly rejected.
Troubleshooting
Keypresses are not detected
Follow #Setup.
Repeated keypress events
If you are having keypress repeating problems (each button press is echoed multiple times), examine the output of irw
. The second column value is the repeat count. This will increment when repeated signals are detected. Each decoded button press with its count reset to "00" is reported as a separate button press event by lircd.
To fix this problem, generally the "gap" parameter sampled by irrecord
in the device_name.lircd.conf
file should be adjusted, often to a much larger value (e.g., from 44968 up to 113975).
After editing/adjusting any lircd configuration file, be sure to restart lircd (as shown above).
Final configuration
Write an lircrc file for your end user application. This file is used by all client programs built with lirc support that attach to lircd to read IR control events. Edit ~/.lircrc
to issue commands to the program to be controlled. Test this configuration by running:
$ ircat prog
to see if the correct "config" strings for program prog
are being output when you press all the buttons you wish to use. Note: If ~/.lircrc
is not read by your application or just does not work, an alternate default location is ~/.config/lircrc
.
Final testing
Finally, run your end user application and test remote control button presses to control it. If it works, you are done! If not, review and repeat the above sections as necessary to get each configuration step working before proceeding to the next step or section.