Launching Linux Apps with an IR Remote

From my last post you might be able to tell that I was interested in doing this so I could switch from Boxee Beta to Hulu Desktop with the use of my MCE remote in Linux and that’s just what I did. Here’s How:

Prerequisite Program: LIRC

The first thing I had to do was figure out what the keys on my remote are referred to as in LIRC. To do this they have a very handy terminal command “irw”. After you run irw just press the key on your remote you want to use and it will show you the key name followed by the remote name.

Example Output for “Up” key and “mceusb” remote:

In my case on the MCE remote the infamous “Green Button” came up as RecTV and the remote itself is called mceusb. So with that info I wanted to use that button to close Boxee and open Hulu and here’s how I did it:

Run “sudo nano /home/user/.lircrc” Replace user with your username.
Typed in:

begin
prog = irexec
remote = mceusb
button = RecTV
config = killall Boxee; huludesktop&
end

Save by pressing ctrl-o and exit with ctrl-x

The last step to get this to work is to set irexec as a startup application and reboot.

So here’s the breakdown of what was just entered, “begin” of course just begins this remote command, pretty easy so far, and prog = irexec specifies the target program irexec to receive the command which comes with the LIRC package, in Ubuntu at least, and helps with executing terminal commands from the LIRC compatible remotes.

Next is remote = mceusb now yours might be a different brand or model so you’ll want to refer to the output of the irw command (above).

Following the remote line is now the line for the button you want to use to launch the application in my case I want the “Green Button” which is output by irw command as RecTV so my line was button = RecTV.

Here’s where the fun starts, after config = is where we enter in the terminal command to be run when the button is pressed so if your familiar with terminal feel free to go nuts but if not here’s what I wrote. First I use killall Boxee which looks for all running processes named Boxee and stops or kills them, then I used huludesktop to launch the huludesktop app what’s important here to is I separate them by semicolon “;” and I do this for a few reasons, first to be able to run a second command and second the semicolon instructs the computer to run the second command even if the first command fails. This is important for me because if Boxee is not running I don’t want it to wait for Boxee to close (which would never happen) before opening Hulu Desktop.

Finally I end the command with & which allows irexec to be ready for the next remote button press without waiting for Hulu Desktop to close. So all together it of course becomes config = killall Boxee; huludesktop& which is then ended by “end” in the last line. After that you can start another line below it with begin and add another command for another button. Hope this helps someone. Cheers.

P.S. I also did the opposite with the Menu key to get back to Boxee, Full Script here:

begin
prog = irexec
remote = mceusb
button = RecTV
config = killall Boxee; huludesktop&
end
begin
prog = irexec
remote = mceusb
button = DVD
config = killall huludesktop; /opt/boxee/run-boxee-desktop&
end

Have a question or comment? Why not leave a Reply?