<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; LIRC</title>
	<atom:link href="http://www.g-loaded.eu/tag/lirc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>How to configure and use LIRC</title>
		<link>http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/</link>
		<comments>http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/#comments</comments>
		<pubDate>Tue, 10 Jan 2006 13:58:34 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Compiling]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[LIRC]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Remote]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/</guid>
		<description><![CDATA[<abbr title="Linux Infrared Remote Control">LIRC</abbr> is basically a small server which can decode or transmit infra-red signals. This is a tutorial about how to set up the LIRC server and how to use it in order to control your system or specific LIRC-enabled applications with a remote control. Examples of simple or more complicated setups are also provided.]]></description>
			<content:encoded><![CDATA[<p><abbr title="Linux Infrared Remote Control">LIRC</abbr> is basically a small server which can decode or transmit infra-red signals. This is a tutorial about how to set up the LIRC server and how to use it in order to control your system or specific LIRC-enabled applications with a remote control. Examples of simple or more complicated setups are also provided.<br />
<span id="more-156"></span></p>
<h4>Prerequisites</h4>
<p>In order to use LIRC you will need the necessary hardware components, a remote control and an infrared receiver. LIRC supports a lengthy list of such devices. You can check if your equipment is supported at <a href="http://lirc.sourceforge.net/remotes/" title="Remote Controls supported by LIRC">this page</a>.</p>
<p>Next thing is to download the latest stable LIRC package from the <a href="http://www.lirc.org/" title="LIRC homepage">project page</a> and configure it properly for your equipment. For this article I&#8217;ll use the traditional way of compiling and installing software, so some such experience is required from your part. Of course, if you are into package building, you can build your own RPM or DEB package.</p>
<h4>Configure, Compile, Install</h4>
<p>Extract the LIRC package in a temporary directory (<code>~/tmp/</code>):</p>
<pre class="console"># tar -xzvf lirc-X.X.X.tar.gz -C ~/tmp/</pre>
<p>The most important part of the LIRC pre-compilation configuration is the choice of the appropriate driver for your hardware. For more info check the <a href="http://www.lirc.org/html/index.html">LIRC Documentation</a>. Normally, if you <em>know your hardware</em>, change to the directory where you have extracted the LIRC package and issue the following command in order to check which driver name you should use:</p>
<pre class="console"># ./configure --help</pre>
<p>Next, configure the package for your system. Because some kernel modules are built together with LIRC, you will need to have the <em>kernel development</em> package (eg <code>kernel-devel</code>) for your running kernel installed. To configure LIRC issue the command:</p>
<pre class="console"># ./configure &#92;
--prefix=/usr &#92;
--with-x &#92;
--with-transmitter &#92;
--enable-sandboxed &#92;
--with-moduledir=/lib/modules/$(uname -r)/extra/lirc &#92;
--with-kerneldir=/path/to/kernel/headers &#92;
--with-driver=DRIVER
</pre>
<p>Substitute <code>DRIVER</code> with the appropriate driver name and edit the path to your kernel headers/sources in the <code>--with-kerneldir</code> option. Note that the <code>--with-kerneldir</code> option can be safely omitted.<br />
We use the <code>--enable-sandboxed</code> option, so that the installation script does not try to create any device nodes for LIRC. An UDEV rule, that we will create later on, will take care of this.</p>
<p>If the configuration script fails due to missing dependencies, make sure you have all the necessary development tools, libraries and kernel headers installed in your system. Just read carefully the on-screen error messages to see what is missing.</p>
<p>After this configuration is finished, you will see a message in your terminal about which LIRC module will be used. <strong>Take a note</strong> of the module name, as you will need it later on.</p>
<p><em>NOTE</em>: On Fedora, I was not able to build the required <code>lirc_gpio</code> module. My IR receiver is attached on my KWorld TV tuner card, so this module was absolutely needed. In such a case you will probably want to read my post about the <a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/">The Complete Fedora Kernel Headers</a>.</p>
<p>Next, proceed to the LIRC compilation:</p>
<pre class="console"># make</pre>
<p>and installation. This step is needed to be done as <strong>root</strong>:</p>
<pre class="console"># make install</pre>
<p>If for any reason you want to uninstall all LIRC files, from within our current directory, issue the command:</p>
<pre class="console"># make uninstall</pre>
<p><strong>Special Note</strong>: Before you update your system kernel at some later time, you will need to uninstall LIRC. After the kernel upgrade, you will have to repeat the previous configuration, compilation and installation steps, so that the LIRC module is built for your new kernel.</p>
<p>The final step is to create an UDEV rule, so that the LIRC devices are created properly and with appropriate permissions.</p>
<p>Create a text file, named <code>10-lirc.rules</code>, in the <code>/etc/udev/rules.d/</code> directory and add the following to it:</p>
<pre class="codesnp">KERNEL=="lirc[0-9]*", NAME=="lirc%n", GROUP=="disk", MODE=="0660"
KERNEL=="lirc0", SYMLINK=="lirc"</pre>
<p>Finally, make sure you add the users you want to have access to the LIRC server to the group <code>disk</code>. Alternatively, if you want all the users to be able to access LIRC, then modify the <code>MODE</code> in the UDEV rule above from <code>MODE==&quot;0660&quot;</code> to <code>MODE==&quot;0666&quot;</code>.</p>
<p>That&#8217;s it.</p>
<h4>The LIRC Server Configuration</h4>
<p>It seems that the LIRC daemon (<code>lircd</code>) does not load the default module (driver) automatically when it starts, so this module should be loaded manually.</p>
<p>To load the appropriate module and the LIRC server at boot time, all you have to do is to add the following lines to the <code>/etc/rc.d/rc.local</code> file. As <strong>root</strong>:</p>
<pre class="codesnp">modprobe MODULE_NAME
lircd</pre>
<p>Substitute <code>MODULE_NAME</code> with the module name you had taken a note of when configuring LIRC. For me, it would be <code>lirc_gpio</code>. The LIRC daemon, by default, uses the driver that was defined during the LIRC pre-compilation configuration.</p>
<p>The LIRC daemon also needs a configuration file (<code>/etc/lircd.conf</code>), which contains the proper addresses of your remote control&#8217;s buttons. The LIRC package contains some ready made remote configs, but I suggest you create your own. Read on&#8230;</p>
<h4>The Remote Control Configuration file</h4>
<p>In this section we will create a configuration file for our remote control by using an utility named <code>irrecord</code>, which was built together with the rest of the LIRC components. Since irrecord is a <code>lircd client</code>, the LIRC daemon needs to be running prior to using this tool.</p>
<p>So, as <strong>root</strong>, load the appropriate LIRC module and start the daemon:</p>
<pre class="console"># modprobe MODULE_NAME
# lircd</pre>
<p>Now, change to a temporary directory and start irrecord:</p>
<pre class="console"># irrecord REMOTE_NAME</pre>
<p><code>REMOTE_NAME</code> is the remote control config file that will be created in the current directory. This will also be the name of your remote control that will be used within the created file. If you need to change it, do it by hand after this operation is finished. All you have to do is to follow the on-screen instructions. Generally, you will be asked to give names for the remote control buttons and to press each one of them.</p>
<p>After you are finished, copy the <code>REMOTE_NAME</code> file into <code>/etc/</code>, naming it <code>lircd.conf</code>. As <strong>root</strong>:</p>
<pre class="console"># cp REMOTE_NAME /etc/lircd.conf</pre>
<p>Kill the running lircd instance and start the daemon again, so that it uses the new configuration:</p>
<pre class="console"># killall lircd
# lircd</pre>
<h4>Applications and LIRC Support</h4>
<p>There are three kinds of applications:</p>
<ol>
<li>Those which could and actually have been built with LIRC support. These act as LIRC clients when there is a running LIRC daemon.</li>
<li>Those which do support LIRC, but have not been compiled with the LIRC support enabled.</li>
<li>Those which do not support LIRC at all.</li>
</ol>
<p>Generally, most multimedia applications, video and audio players, TV viewers and FM tuner applications, support LIRC. Also, many applications provide a method (separate utility or options) to send commands to a running instance of the application. This is particularly useful for programs that belong to the 2nd and 3rd categories. LIRC provides an utility, called <code>irexec</code> (LIRC client), which can be used to execute any command we want. This way, those applications can be controlled with the remote control through LIRC.</p>
<p>In order to use our remote control with a certain application, we have to create a configuration file that contains the mappings between the remote control&#8217;s buttons and the commands that will be executed when each button is pressed.</p>
<p>This file can be:</p>
<ul>
<li>named <code>.lircrc</code> and placed in the user&#8217;s home directory.</li>
<li>named <code>lircrc</code> (without the period in front of the name) and placed in the <code>/etc/</code> directory for system-wide configuration.</li>
</ul>
<p>Information about this file&#8217;s format can be found in the relevant section of the <a href="http://www.lirc.org/html/configure.html#lircrc_format">LIRC Documentation</a>.</p>
<h4>Quick Tests</h4>
<p>Here are some sample <code>.lircrc</code> files, so that you can test your installation. Make sure you have loaded the proper LIRC module and you have started the LIRC daemon. Save one of them as <code>.lircrc</code> and place it in your home directory.</p>
<p><strong>Special Note</strong>: In the following sample config files, substitute the remote control name with the name you have used for your own remote control and the button name with a name of any of your own remote control&#8217;s buttons.</p>
<p>The first two samples will work with Xine and MPlayer respectively. These two players are usually built with LIRC support and, when launched, they act as LIRC clients.</p>
<p>Load Xine and press the specified button on your remote control. It should toggle between full-screen and window-mode.</p>
<pre class="codesnp">
# .lircrc - XINE sample test
begin
    prog = xine
    remote = KWTV878RF
    button = ZOOM
    config = ToggleFullscreen
    repeat = 0
end
</pre>
<p>Use the following config with MPlayer.</p>
<pre class="codesnp">
# .lircrc - MPLAYER sample test
begin
    prog = mplayer
    remote = KWTV878RF
    button = ZOOM
    config = vo_fullscreen
    repeat = 0
end
</pre>
<p>For applications that are not LIRC clients themselves, but which provide a method to send commands to a running instance of the application, the configuration is a bit different. The LIRC client <code>irexec</code> is used in these cases. When you press a button on the remote control, <code>irexec</code> executes the specified command. This requires that <code>irexec</code> is running. Start it as a user:</p>
<pre class="console"># irexec</pre>
<p>Save the following as <code>.lircrc</code> and launch TVtime. The specified button on the remote control should toggle between full-screen and window-mode.</p>
<pre class="codesnp">
# .lircrc - TVtime sample test
begin
    prog = irexec
    remote = KWTV878RF
    button = ZOOM
    config = tvtime-command TOGGLE_FULLSCREEN
    repeat = 0
end
</pre>
<p>To start <code>irexec</code> and have it run in the background, start it as shown below:</p>
<pre class="console"># irexec &#038;</pre>
<p>To kill it:</p>
<pre class="console"># killall irexec</pre>
<h4>Some hints for more complicated configurations</h4>
<p>Here are some hints for those of you who need complicated setups.</p>
<h5>Toggle Buttons</h5>
<p>You can create <strong>toggle buttons</strong>, for example you can set the same button to <em>Play</em> or <em>Pause</em> a video stream, by setting two <code>config = command</code> directives. They will be executed in turns. For example:</p>
<pre class="codesnp">
# Toggle button example
begin
    prog = irexec
    remote = remoteA
    button = buttonA
    config = play_command
    config = pause_command
    repeat = 0
end
</pre>
<p>Using this configuration, when <code>buttonA</code> is pressed for the first time, the <code>play_command</code> is executed. The second time <code>buttonA</code> is pressed, the <code>pause_command</code> is executed.</p>
<h5>Modes</h5>
<p>Let&#8217;s assume that you want to control many applications with your remote control. Some of them are LIRC clients and some are controlled through <code>irexec</code>. You can define various <strong>modes</strong> (groups of button to command mappings), one for each application.</p>
<p>First of all, read the <code>.lircrc</code> format page from the <a href="http://www.lirc.org/html/configure.html#lircrc_format">LIRC Documentation</a> very carefully.</p>
<p>Keep in mind the following rule:</p>
<blockquote><p>Each time you start a LIRC client and there is a mode within your configuration with a name equal to the application&#8217;s name, then this mode is automatically entered.</p></blockquote>
<p>This means that if there is a mode named <em>mplayer</em> inside <code>.lircrc</code> and you start the mplayer program, which is a LIRC client, then the mplayer mode is automatically entered and only the button mappings that exist within this mode are functional.</p>
<p>Save the following as <code>~/.lircrc</code>, substitute the remote control name and button names with your own, and start irexec:</p>
<pre class="codesnp">
# Example with modes
# MAIN BEGIN (irexec mode) - Application Selection Mode
# ---------------
begin irexec
    begin
        prog   = irexec
        remote = KWTV878RF
        button = 1
        # Start TVtime
        config = tvtime --window &#038;
        # Enter tvtime mode
        mode = tvtime
    end
    begin
        prog   = irexec
        remote = KWTV878RF
        button = 2
        # Start Totem player and play DVD
        config = totem dvd:/ &#038;
        # Enter totem mode
        mode = totem
    end
    begin
        prog   = irexec
        remote = KWTV878RF
        button = 3
        # Start Xine and play DVD
        config = xine dvd:/ --hide-gui &#038;
        # Enter xine mode
        mode = xine
    end
end irexec
# ---------------
# MAIN END (irexec mode end)
# APP MODES BEGIN
# ---------------
# tvtime mode
begin tvtime
    begin
        prog = irexec
        button = POWER
        config = tvtime-command QUIT
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = irexec
        button = ZOOM
        config = tvtime-command TOGGLE_FULLSCREEN
    end
end tvtime
# totem mode
begin totem
    begin
        prog = irexec
        button = POWER
        config = totem --quit
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = irexec
        button = ZOOM
        config = totem --fullscreen
    end
end totem
# xine mode
begin xine
    begin
        prog = xine
        button = POWER
        config = Quit
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = xine
        button = ZOOM
        config = ToggleFullscreen
    end
end xine
# ---------------
# APP MODES END
</pre>
<p>I hope this example is clear enough. What is going on here is that when <code>irexec</code> (LIRC client) is executed, then the <em>irexec mode</em> is entered. When you press button &quot;1&quot;, then TVtime is launched and the <em>tvtime mode</em> is entered. When you press the &quot;POWER&quot; button, TVtime quits and the <em>irexec mode</em> is entered etc. etc.</p>
<p>Furthermore, even if you do not start <code>irexec</code>, when you launch any LIRC enabled application, like Xine, MPlayer, Gnomeradio etc, then the appropriate mode will be entered automatically and you will be able to control this application remotely.</p>
<p>As you have probably already read in the <a href="http://www.lirc.org/html/configure.html#lircrc_format">LIRC Documentation</a>, you can modularize this configuration by keeping each application mode in a separate file. Just don&#8217;t forget to include those separate files by adding a line like the following in <code>~/.lircrc</code>. For example:</p>
<pre class="codesnp">include ~/.lirc/tvtime.lircrc</pre>
<h4>Final Notes</h4>
<p>Maybe you will need some time to familiarize yourself with the <code>.lircrc</code> format and probably more time reading the LIRC documentation, but you will be satisfied with the result.</p>
<p>For information about what commands are available for each application, please refer to the application&#8217;s documentation, project web site or support forum.</p>
<p>Also, if you need more information or support for LIRC, please ask your questions in relevant web forums. I have written all I know in this guide, so I am afraid I cannot help you more.</p>
<p>LIRC can do more things, for example it can be used to transmit IR signals or to connect to other LIRC servers accross the network. These have not been covered, not only because I consider such info as &quot;too much&quot; for a new user, but also because I have not been able to devote any time to experiment with these features.</p>
<p>This guide was written while using a Fedora 4 system.</p>
<h4>Further Reading</h4>
<p>You should read:</p>
<ol>
<li><a href="http://www.lirc.org/html/index.html">The LIRC Manual</a> (Documentation)</li>
</ol>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/">How to configure and use LIRC</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/09/09/kernel-2617-and-lirc_gpio-driver/" rel="bookmark">Kernel 2.6.17 and lirc_gpio driver</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/" rel="bookmark">The Complete Fedora Kernel Headers</a></li>
<li><a href="http://www.g-loaded.eu/2005/10/30/creative-pc-cam-750/" rel="bookmark">Creative PC-CAM Series webcams in linux</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/20/build-a-single-native-kernel-module/" rel="bookmark">Build a single native kernel module</a></li>
<li><a href="http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/" rel="bookmark">How to Disable IPv6 in Fedora and CentOS</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

