Linux HOWTOs

About | Home | Search


ERROR: Slooooow dooooown... this page load was delayed.

HOWTO: lirc
Description: Linux Infrared Remote Control
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# LIRC
# ====
# Covered here are libirman (which lirc uses) and lirc (Linux Infrared
# Remote Control).

# If you need to uninstall them, or just clean up files from an old version
# before installing a new one, skip down to the bottom for instructions.

# Sometimes I'll include instructions here for a pre-release or for
# installing it from CVS because the latest stable release won't build
# for me.

# Prerequisites (all versions):
# dialog - comes with most (all?) distributions (for setup.sh)
# modutils' depmod
# libusb
# svgalib (for smode2)
# XFree86 or X.org (for irxevent and xmode2)
# mktemp
# A Linux kernel
# libirman (below)
# PortAudio
# ALSA


# libirman 0.4.4
# ==============
cd
test -f installed/libirman-0.4.4.tar.gz &&
 mv installed/libirman-0.4.4.tar.gz .
test ! -f libirman-0.4.4.tar.gz &&
 wget http://lirc.sourceforge.net/software/snapshots/libirman-0.4.4.tar.gz
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "libirman-*" -exec rm -r {} \;
tar xzvf ~/libirman-0.4.4.tar.gz
cd libirman-0.4.4
test $UID = 0 && chown -R root:root .
./configure
make
su -c "make install ; ldconfig"
cd
mkdir -p -m 0700 installed
rm -f installed/libirman-*.tar.*
mv libirman-0.4.4.tar.gz installed/


# LIRC from CVS
# =============
# Prerequisites (beyond those listed above):
# autoconf
# automake
# libtool
# help2man

# The last time I tried 0.8.0, I was using Linux kernel 2.6.16.19 and gcc
# 4.0.3 and it wouldn't build for me.  The CVS version did.  You may want
# to try version 0.8.0 below first though, in case the CVS version has
# undiscovered bugs that 0.8.0 doesn't.

cd
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "lirc-*" -exec rm -r {} \;
test -d ./lirc && ( cd lirc ; cvs update )
test ! -d ./lirc && (
  # Hit enter for the password
  cvs -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc login
  cvs -z8 -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc \
   co lirc
)
cd lirc
test $UID = 0 && chown -R root:root .
test -f ./Makefile && make distclean
./autogen.sh

## setup.sh will ask you questions (via dialog) about your type of
## TV card.  For my particular Happauge card I do this:
# Hit enter on "Driver configuration"
# Hit enter on "TV card"
# Hit enter on "Hauppauge TV card (new I2C layer required)"
# Hit enter on "Save configuration & run configure"
## Then configure runs and I move on.
./setup.sh

make

# Become root to install it
su

make install
ldconfig
chown -R $USER .
chmod -R u+w .

# If you use udev:
cp contrib/lirc.rules /etc/udev/rules.d/

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/lirc-*.tar.*
echo "lirc was installed from CVS, source is in ~/src/lirc" > \
 installed/lirc.README
chmod 700 installed/lirc.README

# Skip down to the bottom for some notes about configuration


# LIRC 0.8.2
# ==========
# FYI, I haven't tried this one since 0.8.0, I've been using the
# CVS version recently

cd
test -f installed/lirc-0.8.2.tar.bz2 &&
 mv installed/lirc-0.8.2.tar.bz2 .
test ! -f lirc-0.8.2.tar.bz2 &&
 wget http://download.sf.net/lirc/lirc-0.8.2.tar.bz2
mkdir -p -m 0700 src
cd src
test -d ./lirc && rm -r ./lirc
find -maxdepth 1 -type d -name "lirc-*" -exec rm -r {} \;
tar xjvf ~/lirc-0.8.2.tar.bz2
cd lirc-0.8.2
test $UID = 0 && chown -R root:root .

## setup.sh will ask you questions (via dialog) about your type of
## TV card.  For my particular Happauge card I do this:
# Hit enter on "Driver configuration"
# Hit enter on "TV card"
# Hit enter on "Hauppauge TV card (new I2C layer required)"
# Hit enter on "Save configuration & run configure"
## Then configure runs and I move on.
./setup.sh

make

# Become root to install it
su

make install
ldconfig
chown -R $USER .
chmod -R u+w .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/lirc.README installed/lirc-*.tar.*
mv lirc-0.8.2.tar.bz2 installed/

# Skip down to the bottom for some notes about configuration


# Configuration
# =============
# Become root
su

# In my case (a Happauge TV card), I use a kernel module.  It is
# installed into /lib/modules/`uname -r`/misc/
/sbin/rmmod lirc_i2c lirc_dev
sleep 2
/sbin/modprobe lirc_i2c
dmesg|tail -4

# Be aware that if you use devfs or udev, you may need to set it up to
# create a /dev/lirc symlink pointing to the real device file (ie.
# /dev/lirc/0)

# Allow all users to connect to lircd
# (or add a lirc group, 'chown root:lirc /dev/lircd', and
# 'chmod 660 /dev/lircd', and add users to the group)
chmod 666 /dev/lircd

# Test it by starting mode2 and hitting buttons on your remote (while aiming
# it at your receiver):
mode2

# Make sure it's not already running and start the daemon:
test -f /var/run/lircd.pid &&
 ( kill `cat /var/run/lircd.pid` ; sleep 2 )
killall lircd
sleep 2
killall -9 lircd > /dev/null 2>&1
sleep 2
/usr/local/sbin/lircd

# To test further, run this and hit more buttons:
irw

# Watch the log file:
tail -f /var/log/lircd

# Set logrotate to rotate the log when it becomes greater than 100k:
cat << EOF > /etc/logrotate.d/lirc
/var/log/lircd {
    rotate 1
    size=100k
    copytruncate
}
EOF

## Add something like this to /etc/rc.d/rc.local to start it on boot-up:
#if [ -x /usr/local/sbin/lircd ]; then
#  echo "Starting lircd..."
#  /usr/local/sbin/lircd
#fi

# If you're setting up lirc for MythTV, read this:
# http://mythtv.org/docs/mythtv-HOWTO.html#toc8.5

# Become yourself again
exit

# Read this for other info:
lynx ~/src/lirc*/doc/html/index.html


# If you ever want to uninstall libirman, this should do it:
cd
su
test -d src/libirman-* && ( cd src/libirman-* ; make uninstall )
rm -f /usr/local/bin/workmanir /usr/local/etc/irman.conf \
 /usr/local/include/irman.h /usr/local/lib/libirman.a
exit
find ~/src -maxdepth 1 -type d -name "libirman-*" -exec rm -r {} \;
rm -f ~/installed/libirman-*.tar.*

# If you ever want to uninstall lirc, this should do it:
cd
su
test -d src/lirc && ( cd src/lirc ; make uninstall )
test -d src/lirc-* && ( cd src/lirc-* ; make uninstall )
( cd /etc ; rm -f lircd.conf lircmd.conf )
( cd /usr/local/bin ; rm -f ircat irexec irpty irrecord irsend irw \
 irxevent lircrcd mode2 smode2 xmode2 )
test -d /usr/local/include/lirc && rm -r /usr/local/include/lirc
( cd /usr/local/man/man1 ; rm -f ircat.1 irexec.1 irpty.1 irrecord.1 \
 irsend.1 irw.1 irxevent.1 lircrcd.1 mode2.1 smode2.1 xmode2.1 )
( cd /usr/local/man/man8 ; rm -f lircd.8 lircmd.8 )
( cd /usr/local/sbin ; rm -f lircd lircmd )
rm -f /usr/local/lib/liblirc_client.* /etc/logrotate.d/lirc
/sbin/rmmod lirc_i2c lirc_dev
( cd /lib/modules/`uname -r`/misc ; rm -f lirc_dev.* lirc_i2c.* )
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "lirc-*" -exec rm -r {} \;
rm -f ~/installed/lirc.README ~/installed/lirc-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>