Lirc

From ArchWiki

Jump to: navigation, search


This howto is for using lirc with a serial infrared device

Contents

[edit] Name

LIRC stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.

[edit] Installation

First install lirc with pacman:

pacman -S lirc

Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device isn't connected to ttyS0, you'll 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.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 your dmesg:

dmesg|grep ttyS

[edit] Building the lirc_serial module for another ttySx

Update abs

(as root) abs

copy the lirc files to a directory you choose yourself:

cp /var/abs/extra/system/lirc /some/dir

goto /some/dir

edit the PKGBUILD in that directory replace the line:

./configure --enable-sandboxed --prefix=/usr \
    --with-driver=all \\
    return 1[/code]

with:

./configure --enable-sandboxed --prefix=/usr \
    --with-driver=com2 \
    || return 1[/code]

where you replace com2 with the com-port you need.

build and install the package:

makepkg
(as root) pacman -U lirc-version.pkg.tar.gz

[edit] 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's build into the kernel you'll have to do the following (remember that it is build into the kernel, you will need to make some changes later too)

You'll 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 shouldn't show any errors, and the modules lirc_serial should be listed in lsmod

[edit] Making configuration file

You'll need a configuration file for your remote control. The easiest way is to look on the lirc site and hope your device has already a config file: list of remotes on the lirc site

If so, download your file and save it as /etc/lircd.conf

If your device doesn't have already a config file, you'll have to create the file yourself with the command:

irrecord -d /dev/lirc0 /tmp/my_remote

Just follow the instructions. The resulting file, /tmp/my_remote, should then be copied to /etc/lircd.conf. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into /etc/lircd.conf:

cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 >/etc/lircd.conf


[edit] Testing

First start the lircd daemon:

as root

/etc/rc.d/lircd start

A good way to see if lirc is running is to run irw.

irw

When you press a button, you should get something like this:

0000000000000001 00 play sony2
0000000000000001 01 play sony2
0000000000000001 02 play sony2
0000000000000001 03 play sony2

In this case my remote is called sony2, the button is called play, and lirc has seen it 4 times.

[edit] Run lirc at bootup

Remember if you had to execute the setserial command while loading the module?

If so, Your serial port support is compiled into the kernel

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

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

[edit] Your serial port support is compiled into the kernel

This is more complicated, you can't just add the lirc_serial to the modules list in /etc/rc.conf, as the serial port should be released first.

So I created a custom startup script to fix this problem

/etc/rc.d/start_lirc

#!/bin/bash
#/etc/rc.d/start_lirc
#releases ttySx and loads lirc_serial module

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
 start)
   stat_busy "release ttySx"
       setserial /dev/ttySx uart none
       #load lirc module
       modprobe lirc_serial
   stat_done
   ;;
 stop)
   stat_busy "unload lirc module"
       rmmod lirc_serial
   stat_done
   ;;
 restart)
   $0 stop
   $0 start
   ;;
 *)
   echo "usage: $0 {start|stop|restart}"
esac
exit 0

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

[edit] Enable lirc support in xine

Now lirc works, but you have no program that can communicate with lirc. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with lirc.

[edit] compile xine with lirc support

download the xine-ui pkgbuild from the cvs tree

Add " --enable-lirc" to the "./configure" line

compile:

makepkg

uninstall old xine-ui and install the new one

pacman -R xine-ui
pacman -A xine-filename.pkg.tar.gz

[edit] configure xine to use lirc

let xine produce a default .lircrc file. In your home directory, type:

xine --keymap=lirc>.lircrc

now, in order to have a functioning xine+lirc, edit the .lircrc file to your preferences.

Have fun! :-)

However, you may choose to configure lirc to control more than just xine. If this is the case, you will need to manually edit the .lircrc file, and add elements.

Xine-ui Mplayer Totem Vlc Rhythmbox

all work with lirc, but you must enable lirc support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!

In any event, should you require more information, you may consult http://gentoo-wiki.com/HOWTO_LIRC, which is an incredibly in-depth detailed howto regarding all aspects of Lirc and its configuration.

(I would have cut relevant parts from that wiki, but I am not sure if I am allowed to do that) --Pyrrhicvictory 16:53, 18 July 2008 (EDT)

[edit] Configure Amarok2 to use Lirc

Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.


File ~/.lircrc
##amarok2

begin
button = Play
prog   = irexec
repeat = 0
config = qdbus org.mpris.amarok /Player Play
end

begin
button = Pause
prog   = irexec
repeat = 0
config = qdbus org.mpris.amarok /Player Pause
end

begin
button = Stop
prog   = irexec
repeat = 0
config = qdbus org.mpris.amarok /Player Stop
end

begin
button = Skip
prog   = irexec
repeat = 0
config = qdbus org.mpris.amarok /Player Next
end

begin
button = Replay
prog   = irexec
repeat = 0
config = qdbus org.mpris.amarok /Player Prev
end

--Pyrrhicvictory 16:53, 16 August 2008 (EDT)

Personal tools