Enhanced VLC lirc remote control

I am Kubuntu 6.10 user and I use VLC as a client for watching DVB-T streams. I would like to use VLC + infra red remote control the same way as I use remote control for a television: program +/-, volume +/-, jump to position 3 when button 3 is pressed,... Build-in lirc commands are only for basic control in the movie-playing mode, but I need to use other commands from rc interface - mainly "goto x" function. So the goal was to be able to use goto function with lirc.


  1. Hardware
  2. VLC + lirc
  3. Load lirc modules
  4. Scripts
  5. .lircrc
  6. Sources

Hardware

I have IR remote + receiver from Technisat AirStar2 DVB-T card. Remote control unit is Technisat TTS35AI.

TTS35AI

VLC + lirc

I suppose you have working VLC with working lirc. Nice howto is at gentoo-wiki.com.


Load lirc modules

My lircd loading script:

#start/stop script for lircd+vlc for Kubuntu 6.10
start() {
   echo "Starting lirc support..."
   sudo setserial /dev/ttyS0 uart none       #serial port down
   sudo /sbin/modprobe lirc_serial           #load module
   sudo /sbin/modprobe lirc_dev           #load module
   sudo /usr/local/sbin/lircd --driver=default --device=/dev/lirc0 --output=/dev/lircd --pidfile=/var/run/lircd.pid --listen  #run lirc daemon
   sudo chmod 666 /dev/lircd                 #access
   sudo irexec -d   #daemon to pass ir commands
}

stop() {
   echo "Stoping lirc support..."
   sudo /usr/bin/killall -w lircd                #kill lirc daemon
   sudo /sbin/rmmod lirc_serial              #unload module
   sudo /sbin/rmmod lirc_dev                 #unload module
   sudo setserial /dev/ttyS0 uart 16550A     #serial port up
}

restart() {
   stop
   sleep 2
   start
}

case "$1" in
'start')
  start
  ;;
'stop')
  stop
  ;;
'restart')
  restart
  ;;
*)
echo "usage $0 start|stop|restart"
esac
exit 0

VLC rc + scripts

It is neccesary to run vlc with rc interface to use all the supported commands (see vlc help). I use this script to run VLC with rc intf. Lircd is loaded and later unloaded. I have a desktop shortcut icon and I had to change properties of the shortcut to run in terminal. The other option is vlc --fake-tty option, but this uses 100 % CPU :-(

#/bin/bash
/home/ondra/.vlc/ovladac.sh start
vlc -I rc --rc-host localhost:12345 /home/ondra/playlist.m3u   
/home/ondra/.vlc/ovladac.sh stop

I use irexec to pass commands to VLC rc intf. Commands can be passed with netcat: echo "vlc_rc_command" | netcat localhost 12345 -q 1 (q means quit after 1 s). Commands are written in scripts, which are executed with irexec:

Here is a script, which is executed when remote button 1 is pressed. The others are similar.

cat play1.sh
#!/bin/bash
echo "goto 0" | netcat localhost 12345 -q 1

.lircrc

The last part of my .lircrc file. There are defined actions for all requested buttons. irexec executes concerned shell script.

# remote numbers
begin
        prog = irexec
        button = 1
        config = /home/ondra/.vlc/play1.sh  &\n
end

begin
        prog = irexec
        button = 2
        config = /home/ondra/.vlc/play2.sh  &\n
end

begin
        prog = irexec
        button = 3
        config = /home/ondra/.vlc/play3.sh  &\n
end

begin
        prog = irexec
        button = 4
        config = /home/ondra/.vlc/play4.sh  &\n
end

begin
        prog = irexec
        button = 5
        config = /home/ondra/.vlc/play5.sh  &\n
end

begin
        prog = irexec
        button = 6
        config = /home/ondra/.vlc/play6.sh  &\n
end

begin
        prog = irexec
        button = 7
        config = /home/ondra/.vlc/play7.sh  &\n
end

begin
        prog = irexec
        button = 8
        config = /home/ondra/.vlc/play8.sh  &\n
end

begin
        prog = irexec
        button = 9
        config = /home/ondra/.vlc/play9.sh  &\n
end

begin
        prog = irexec
        button = 0
        config = /home/ondra/.vlc/play0.sh  &\n
end
begin
        prog = irexec
        button = Menu
        config = /home/ondra/.vlc/pause.sh  &\n
end

Enjoy :-)


Sources

netcat
VLC forum
vogo's blog at abclinuxu.cz
gentoo-wiki.com
picture of remote control unit
 W3C  XHTML 1.1   W3C  CSS 3.0  Ondrej Kuda January 7th 2007