Ack! This site is moving to since Comcast's efforts to improve their world's worst customer service ranking apparently include terminating web hosting for their existing customers.

Fun With Lirc

I wondered the other day if there was an easy way I could control mplayer on my linux box using my android phone, and came up with a ridiculous concotion that will actually allow anything with a web browser to control it (which includes my android phone).

Warning: the only security in what follows is provided by the security you get from isolating your local area network.

First, you need to setup mplayer to be controlled by lirc. This involves putting lots of junk like this in your ~/.lircrc file:

    button = Pause
    prog = mplayer
    config = pause

This particular entry says that the remote button named "Pause" should execute the "pause" action of mplayer if mplayer happens to be listening for remote events from lirc.

Of course, you also need the lirc software installed and a lirc config file setup to have at least one remote control defined.

yum install lirc
chkconfig --level 5 lirc on

Since I am going to be simulating the remote, it doesn't matter which one I pick, but I need a valid config file for the lirc daemon to look at, so visit and pick a valid config (random probably works - I used the IMON_RSC simply because my old computer had one built into the case and I was familiar with the file). Copy this file to /etc/lirc/lircd.conf.

You still need to fiddle some startup parameters for the lircdaemon. Fill in the /etc/sysconfig/lirc file with these changes:


The --allow-simulate option is important for the web page to work. The udp driver was picked because there isn't a /dev/lirc device, so the simplest way to keep the daemon happy is to tell it to listen for network packets it will never get.

service lircd start

I you do a man irsend you can read about the SIMULATE command you can now use to have the lircd send out remote button presses just as if a real remote had actually pressed a button. Naturally, it is only one small step from a command I can run to a .cgi script to run the commands for me:

use CGI qw/:standard/;
use URI::Escape;

my $cols = 3;

my %button_codes;

if (param()) {
   my $button_name = param('button_name');
   my $button_code = $button_codes{$button_name};
   system("irsend SIMULATE '$button_code 00 $button_name IMON_RSC'");

my @button_names = sort(keys(%button_codes));
my $i;

print header,
      start_html(-title=>'IRMON_RSC Buttons',
      "<table border=\"0\" cellpadding=\"5\">\n";

   while (scalar(@button_names) > 0) {
      print "<tr>\n";
      for ($i = 0; $i < $cols; ++$i) {
         print "<td>";
         if (scalar(@button_names) > 0) {
            my $b = shift(@button_names);
            print submit(-name=>'button_name',-value=>$b);
         } else {
            print '&nbsp;';
         print "</td>";
      print "</tr>\n";

print "</table>\n",

The bigbuttons.css stylesheet that cgi script points at is just used to crank up the size of the buttons so you don't have to zoom in on the web page when using it from the phone. It looks like:

input {
font-weight: bold;
font-size: 250%;

Naturally, for this to work, you also need to be running a web server that has .cgi scripts enabled (I use the fedora apache package), and have perl and the cgi modules installed (also available in the fedora repos).

Anyway, with all this running, I can connect to my LAN over Wi-Fi from my phone, bring up the cgi script in the web browser, and punch the Pause button when using mplayer, and mplayer will pause.

Spiffy custom web pages with button images rather than text are left as an exercise for the reader, as is implementing more buttons than just Pause, etc. :-).

Of course, if irsend were ported to android and used directly, a much snazzier interface would be possible (like one that automatically sends a Pause when a call is coming in :-).

Page last modified Wed Oct 5 19:19:55 2011