LIRC is a deamon that can translate key presses on a supported remote into program specific commands. In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.

+

LIRC is a daemon that can translate key presses on a supported remote into program specific commands. In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.

=== The Central Dogma of LIRC ===

=== The Central Dogma of LIRC ===

Line 16:

Line 15:

* The signal is received by the receiver connected to the Linux box.

* The signal is received by the receiver connected to the Linux box.

* The kernel (via the correct module) uses /dev/lirc0 to characterize the pulse-length information from the receiver.

* The kernel (via the correct module) uses /dev/lirc0 to characterize the pulse-length information from the receiver.

* Programs that use LIRC translate the button press info from {{ic|/usr/bin/lircd}} into user-defined actions according to {{ic|~/.lircrc}}.

* Programs that use LIRC translate the button press info from {{ic|/usr/bin/lircd}} into user-defined actions according to {{ic|~/.lircrc}}.

Line 35:

Line 34:

==== Use a Prebuild Config File ====

==== Use a Prebuild Config File ====

−

Identify which remote/IR receiver is to be used and see if {{ic|/usr/share/lirc}} contains a pre-built config file for it. Once identified, create/edit {{ic|/etc/lirc/lircd.conf}} to use an '''include''' statement that points to the selected one.

+

Identify which remote/receiver is to be used and see if {{ic|/usr/share/lirc}} contains a pre-built config file for it. Once identified, create/edit {{ic|/etc/lirc/lircd.conf}} to use an '''include''' statement that points to the selected one.

Example:

Example:

Line 43:

Line 42:

==== Create a Config File ====

==== Create a Config File ====

−

Users with unsupported hardware will need to either find a config file someone else has create (i.e. google) or create one. Creating one is fairly straightforward using the included {{ic|/usr/bin/irrecord}} program which guides users along the needed process. If using a detected remote, invoke it like so:

+

Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one. Creating one is fairly straightforward using the included {{ic|/usr/bin/irrecord}} program which guides users along the needed process. If using a detected remote, invoke it like so:

irrecord --device=/dev/lirc0 MyRemote

irrecord --device=/dev/lirc0 MyRemote

The program will ask users to begin hitting keys on the remote in an attempt to learn it. If all goes well, the user will be prompted to map out each key press to a specific scancode LIRC uses to identify that specific key press. The process should take no more than 10 minutes. When finished, save the resulting file to {{ic|/etc/lirc/lircd.conf}} and proceed.

The program will ask users to begin hitting keys on the remote in an attempt to learn it. If all goes well, the user will be prompted to map out each key press to a specific scancode LIRC uses to identify that specific key press. The process should take no more than 10 minutes. When finished, save the resulting file to {{ic|/etc/lirc/lircd.conf}} and proceed.

−

{{Note|Considering sending the finished config file to the email address mentioned by running the program so they can be made available to others.}}

+

{{Note|Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.}}

== Testing the Remote ==

== Testing the Remote ==

Line 68:

Line 67:

LIRC has the ability to allow for different programs to use the same keypress and result in unique commands. In other words, mplayer and vlc can respond differently to a given key press.

LIRC has the ability to allow for different programs to use the same keypress and result in unique commands. In other words, mplayer and vlc can respond differently to a given key press.

−

Decide which programs are to use LIRC commands. Common programs include:

+

Decide which programs are to use LIRC commands. Common programs include: {{Pkg|mplayer}}, {{Pkg|mythtv}}, {{Pkg|totem}}, {{Pkg|vlc}}, and {{Pkg|xbmc}}.

−

* {{Pkg|mplayer}}

+

−

* {{Pkg|mythtv}}

+

−

* {{Pkg|totem}}

+

−

* {{Pkg|vlc}}

+

−

* {{Pkg|xbmc}}

+

−

{{Note|XBMC implements LIRC in a non-standard way. Users must edit {{ic|~/.xbmc/userdata/Lircmap.xml}} which is a unique xml file, rather than the LIRC standard files the rest of the programs use.}}

+

{{Note|XBMC implements LIRC in a non-standard way. Users must edit {{ic|~/.xbmc/userdata/Lircmap.xml}} which is a unique xml file, rather than the LIRC standard files the rest of the programs use. Interested users should consult the [[Xbmc#Using_a_remote_controller]] article.}}

Users should create the expected files showing LIRC where the various program-specific maps reside:

Users should create the expected files showing LIRC where the various program-specific maps reside:

Line 88:

Line 82:

mythtv

mythtv

vlc

vlc

+

+

{{Note|Providing an exhaustive listing of keymaps for each program is beyond the scope of this wiki article. Many pre-made files unique to each remote/program are available via googling.}}

* Edit {{ic|~/.lircrc}} to contain an '''include''' statement pointing to {{ic|~/.lirc/foo}} and repeat for each program that is to be controlled by LIRC.

* Edit {{ic|~/.lircrc}} to contain an '''include''' statement pointing to {{ic|~/.lirc/foo}} and repeat for each program that is to be controlled by LIRC.

Line 97:

Line 93:

include "~/.lirc/vlc"

include "~/.lirc/vlc"

}}

}}

+

==Troubleshooting==

==Troubleshooting==

=== Remote functions as a keyboard ===

=== Remote functions as a keyboard ===

−

Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as physical key presses like the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device. To disable this, create the following file and restart X:

+

Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as key strokes as if entered from the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device.

+

To disable, create the following file and restart X:

{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|

{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|

Line 109:

Line 107:

EndSection}}

EndSection}}

−

== (Temp placeholder for content to sort) ==

+

Don't forget to alter the {{ic|MatchProduct}} property according to one shown in {{ic|Name}} from output of

== Legacy Info Which Needs to be Modernized and Vetted for Accuracy ==

+

{{Accuracy|Someone with greater knowledge needs vet everything below this line for accuracy.}}

+

{{Out of date|Parts of the following are out-of-date and need to be modernized.}}

+

=== Setup a HID device with LIRC ===

=== Setup a HID device with LIRC ===

Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.

Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.

Line 240:

Line 245:

===Your serial port support is compiled into the kernel===

===Your serial port support is compiled into the kernel===

+

+

{{Out of date|[[initscripts]] is deprecated}}

This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.

This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.

Line 277:

Line 284:

Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}

Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}

Overview

LIRC is a daemon that can translate key presses on a supported remote into program specific commands. In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.

The Central Dogma of LIRC

The list below attempts to show the flow of information from the remote to the program using LIRC:

User hits a button on the remote causing it to transmit an IR or RF signal.

The signal is received by the receiver connected to the Linux box.

The kernel (via the correct module) uses /dev/lirc0 to characterize the pulse-length information from the receiver.

/usr/bin/lircd uses the information from /etc/lirc/lircd.conf convert the pulse-lengths into button press information.

Programs that use LIRC translate the button press info from /usr/bin/lircd into user-defined actions according to ~/.lircrc.

Summary of Required Files

/etc/lirc/lircd.conf - System-level config translating scancodes --> keys. Is specific to each remote control/receiver on the system and can contain configure for multiple remotes and/or receivers if need be.

~/.lirc/foo - User-level config translating of keys --> actions. Is specific to each remote and to application foo.

Installation

Install the lirc-utils package, which is available in the official repositories. The most of LIRC kernel drivers are already included in the mainline kernel. Install the lirc package only, if the hardware requires the lirc_wpc8769l module.

Setup

Some remotes are identified as "keyboards" and function as such without LIRC. This is problematic and can result in a doubling of commands. Test if this is the case by opening a shell or a text editor, and by pressing buttons on the remote itself. If letters/numbers appear, or if the up/down/left/right arrow keys behave as the up/down/left/right arrow keys on the physical keyboard, a workaround to disable this is required. See, LIRC#Remote_functions_as_a_keyboard for a solution before continuing.

The LIRC Config File

Defining /etc/lirc/lircd.conf which is specific to each remote/IR receiver is the first step in setting up a remote.

Note: Common configs are provided by lirc-utils, like those bundled with TV cards that can be installed automatically. The primary source of config files is the LIRC homepage. Check the official list of supported hardware to know, which LIRC kernel modules and lircd driver required.

Use a Prebuild Config File

Identify which remote/receiver is to be used and see if /usr/share/lirc contains a pre-built config file for it. Once identified, create/edit /etc/lirc/lircd.conf to use an include statement that points to the selected one.

Example:

/etc/lirc/lircd.conf

include "/usr/share/lirc/streamzap/lircd.conf.streamzap"

Create a Config File

Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one. Creating one is fairly straightforward using the included /usr/bin/irrecord program which guides users along the needed process. If using a detected remote, invoke it like so:

irrecord --device=/dev/lirc0 MyRemote

The program will ask users to begin hitting keys on the remote in an attempt to learn it. If all goes well, the user will be prompted to map out each key press to a specific scancode LIRC uses to identify that specific key press. The process should take no more than 10 minutes. When finished, save the resulting file to /etc/lirc/lircd.conf and proceed.

Note: Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.

Testing the Remote

Start the LIRC daemon:

# systemctl start lirc

Test the remote using /usr/bin/irw, which simply echos anything received by LIRC when users push buttons on the remote to stdout.

Note: XBMC implements LIRC in a non-standard way. Users must edit ~/.xbmc/userdata/Lircmap.xml which is a unique xml file, rather than the LIRC standard files the rest of the programs use. Interested users should consult the Xbmc#Using_a_remote_controller article.

Users should create the expected files showing LIRC where the various program-specific maps reside:

$ mkdir ~/.lirc
$ touch ~/.lircrc

Populate ~/.lirc with the program specific config files named for each program.

Example:

$ ls ~/.lirc
mplayer
mythtv
vlc

Note: Providing an exhaustive listing of keymaps for each program is beyond the scope of this wiki article. Many pre-made files unique to each remote/program are available via googling.

Edit ~/.lircrc to contain an include statement pointing to ~/.lirc/foo and repeat for each program that is to be controlled by LIRC.

Example:

~/.lircrc

include "~/.lirc/mplayer"
include "~/.lirc/mythtv"
include "~/.lirc/vlc"

Troubleshooting

Remote functions as a keyboard

Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as key strokes as if entered from the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device.
To disable, create the following file and restart X:

Don't forget to alter the MatchProduct property according to one shown in Name from output of

$ cat /proc/bus/input/devices | grep -e IR

For example WinFast for N: Name="cx88 IR (WinFast DTV2000 H rev."

Legacy Info Which Needs to be Modernized and Vetted for Accuracy

The factual accuracy of this article or section is disputed.

Reason: Someone with greater knowledge needs vet everything below this line for accuracy. (Discuss in Talk:LIRC#)

This article or section is out of date.

Reason: Parts of the following are out-of-date and need to be modernized. (Discuss in Talk:LIRC#)

Setup a HID device with LIRC

Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own lirc.conf files become standard HID devices.

Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to lircd.conf.

First we need the /dev/input device for our remote:

$ ls /sys/class/rc/rc0

One of the files should be input#, where the number matches the event# of the device. (To clarify you can check that directory, it will have an event# file.

Note: If you have more than one ir device then there may be multiple directories under /sys/class/rc. Under event#cat name to verify which device you are looking at.

then go to /dev/input/by-id

$ ls -l /dev/input/by-id

You should find a file that symlinks to the input# above, and possibly others with a similar names for mouse events.

Note: Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.

The latest version of the config file for HID remotes exists in the LIRC git repository [1]. Simply save it as /etc/lirc/lircd.conf.

In order to launch the LIRC daemon for HID remote, You must enable evdev module first

# modprobe evdev

Note: LIRC 0.8.6 has changed the default socket location from /dev/lircd to /var/run/lirc/lircd, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the /etc/rc.d/lircd script creates a symlink from /dev/lircd to the /var/run/lirc/lircd socket when it starts the lircd daemon and removes the link when the daemon is stopped.

Serial receivers that depend on lirc_serial

Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.

Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or rebuild the LIRC module. If your device is connected to ttyS0, you can skip this step

To change the options for the lirc_serial module, you edit /etc/modprobe.d/modprobe.conf and add this line:

options lirc_serial io=0x2f8 irq=3

You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:

Loading

Now try to load the serial module:

# modprobe lirc_serial

If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)

If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)

You will have to release the serial port:

# setserial /dev/ttySx uart none

(Replace x with your port number)

Load the module again:

# modprobe lirc_serial

Now it should not show any errors, and the modules lirc_serial should be listed in lsmod

Checking module based receivers

NOTE: This section only applies if your device requires a lirc_[driver] kernel module.

Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.

# mode2 -d /dev/lirc0

If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.

If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.

Your serial port support is compiled as a module in the kernel

This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in /etc/rc.conf