- Hack Your Life! - http://www.hackourlife.com -

Setup Windows Media Center IR Remote for MythTV and XBMC

First and foremost thing to be installed is the lirc package which supports the IR remotes in linux. Install it by doing (make sure your remote is not plugged at this instance, plug it in after the installation has finished)

sudo apt-get install lirc

The basic setup for Media Center remote integration with MythTV, XBMC and some other common programs like vlc, xine, totem etc can be achieved by installing mythbuntu-lirc-generator

sudo apt-get install mythbuntu-lirc-generator

Invoke it at a terminal by doing this

mythbuntu-lircrc-generator

It would generate a bunch of files in ~/.lirc folder in your home directory, and also create a .lircrc file in ~/ or /home/user_name folder. That is all for the basic setup of the IR remotes.

For more advanced setup, and to control other applications, one needs to create ones own button -> function mapping and we would need to include couple of more configuration files in ~/.lircrc. I am going to show you how to use MCE Green button to launch MythTV, use another button say Red to launch XBMC and use the power button to shutdown your computer.

Before we begin, check whether your remote is getting detected properly, to test the IR remote buttons, launch a terminal and type in

irw
Each button press should reveal the name of the button being pressed on the remote, something like this
[1]
In case you are looking for a perfectly Linux compatible Media Center Remote, then you can buy  the one shown below with confidence, as it works seamlessly with Ubuntu 10.04 and Ubuntu 9.10 and probably all other too.
[AMAZONPRODUCT=B000ST7QPA]
Now that you have ensured that your remote is compatible with Linux, we need to install lirc-x, do so by
sudo apt-get install lirc-x
Download and extract the contents of the file below in the ~/.lirc folder
lirc_files.zip [2]
It contains two files, irexec and irxevent (this is an empty file, so don’t worry if you see it to be empty). You might need to modify the button names if your remote has slightly different names for the buttons.
Next, download the zipped file below which has 4 scripts (startMythTV.sh, startXBMC.sh, startIRexec.sh and shutdown.sh) and extract their contents in ~/scripts (or /home/user_name/scripts folder.
scripts.zip [3]

You would have to change the permission of the files to make them executable, run

chmod +x *.sh

inside the ~/scripts folder. Also open startIRexec.sh file using a text editor and replace the string “user_name” with your own username.

Now you need to add the following lines to the ~.lircrc file at the end, you use any text editor to do so.

include ~/.lirc/irexec
include ~/.lirc/irxevent

Lets test the scripts by starting them manually from terminal
~/scripts/startIRexec.sh

Now you should be able to launch MythTV with the Green Media Center button.

Finally we want the irexec (and irxevent) to be auto-started at each boot. So, add this startIRexec.sh
script to Startup Applications Preference from the System > Preferences menu.