Hack79.Take (Remote) Control

Hack 79. Take (Remote) Control

A keyboard and a mouse aren't the only way to control your computer.

While the geek in you probably doesn't mind having a wireless keyboard and mouse to control your multimedia powerhouse computer, it can be a bit cumbersome, especially if you have to share control. Here comes the Linux Infrared Remote Control (LIRC) project to the rescue (http://www.lirc.org).

The LIRC project has the simple goal of letting you use the remote of your choice to control your Linux system. LIRC supports a wide range of infrared receivers, ranging from home-made serial port versions and dongles on TV tuner cards to even Microsoft Windows XP Media Center USB receivers, along with many different remotes ranging from those bundled with some of the above-mentioned receivers to a wide range of universal and programmable remotes. Check out the LIRC web site for further details on supported hardware.

To install LIRC, you can obtain a source tarball from the site, but since it is already available as a package on several platforms check your package manager and your distribution's third party repositories first. For instance, Axel Thimm's ATrpms package repository at http://atrpms.net carries packaged LIRC binaries for all recent Red Hat and Fedora Core releases, installable using your favorite automatic dependency resolution program with the ATrpms repository enabled. The quick version of how to do this with a recent Fedora Core release and the Fedora-provided yum utility is to first install the ATrpms package-signing key

 # rpmimport  http://atrpms.net/RPM-GPG-KEY.atrpms  

Then create a yum config file at /etc/yum.repos.d/atrpms.repo for ATrpms:

 [atrpms]  name=ATrpms for Fedora Core $releasever stable baseurl=http://apt.atrpms.net/fedora/$releasever/en/$basearch/at-stable gpgcheck=1 enabled=1 

With that done, you can now install the necessary LIRC components, with the command:

 # yum install lirc-kmdl-`uname -r` lirc 

Note that those are back-ticks, not single-quotes, and you'll need to be running the latest errata kernel, as ATrpms only actively maintains packages for the latest errata kernel.

The ATrpms packages are built with support for as many different LIRC drivers as possible, covering all standard/popular interfaces, so unless you have some oddball receiver, you should be covered. The following example shows the necessary additions to /etc/modprobe.conf for the IR dongle on a Hauppauge WinTV PVR-250 (assuming you already have the ivtv driver configured for the card):

 # lirc alias char-major-61 lirc_i2c install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_ i2c 

For a serial port IR receiver on COM1, the following should do the trick:

 # lirc alias char-major-61 lirc_serial options lirc_serial irq=4 io=0x3f8 install lirc_serial /bin/setserial /dev/ttyS0 uart none ; \ /sbin/modprobe --ignore-install lirc_serial 

Other receivers require fewer options, needing only an alias line for their specific lirc_* driver. A little poking around the LIRC web site and some Googling should turn up information on just about any receiver.

With your modprobe.conf entries in place, load up your driver, substituting i2c, serial, and so on for <your driver>:

 # /sbin/modprobe lirc_  <your driver>  

The next step is to set up a configuration file for the LIRC daemon, lircd, that'll map IR codes for your particular remote to their corresponding buttons, so you can later assign buttons to functions, rather than IR codes to functions. This configuration file exists as /etc/lircd.conf. Distributed with LIRC are a myriad of configuration files for remotes, contributed by the LIRC user community. You can find them on your system in the directories under /usr/share/doc/lirc-*/remotes. If you don't find one in there for your remote, do a bit of Googling and you may come up with one (if not, check out the man page for irrecord, and you can generate your own).

With the proper lircd.conf file in place, start up lircd, via the command:

 # /sbin/service lircd start 

Now fire up the irw tool, distributed by the LIRC folks, to verify basic functionality. When you press a button on your remote, irw will output the button label associated with the IR code lircd picked up from your receiver, per your lircd.conf.

 $ /usr/bin/irw (control-c to stop) 

If the output looks correct, all that remains is to configure your applications to receive commands from lircd. The majority of Linux multimedia applications have support for LIRC, and details on how to configure LIRC to work with them can typically be found the respective applications' documentation. [Hack #77] includes some tidbits on configuring LIRC to work with MythTV, MPlayer and xine.

Jarod Wilson

Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net