How launch XBMC with MCE Remote “Home” Button on Ubuntu

Having recently installed ubuntu on my HTPC I was keen to get my Microsoft MCE Remote Control working. Initially this is easy to setup with LIRC but its a little trickier to get the buttons mapped the way you want. There is a lot of documentation on the web which doesnt seem to work.

I following the guide here with a few tweaks of my own: http://www.hackourlives.com/setup-windows-media-center-remote-for-mythtv-and-xbmc/

Im only interested in launching XBMC with the “Home” button on the remote, the power button will close XBMC with the default setup.

My setup:

Microsoft MCE Remote with USB IR Receiver
HTPC: Dell Hybrid
Version of ubuntu:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION=”Ubuntu 9.10″

Here are the steps:

1: Install the LIRC package which supports IR remotes for linux

$ sudo apt-get install lirc lirc-modules-source

You will then next to select the correct remote in the GUI which pops up.

2: For basic setup for media centre remote integration with xbmc and mythtv etc install the following:

$ sudo apt-get install mythbuntu-lirc-generator

and run in a terminal:

$ mythbuntu-lircrc-generator

According to the source this creates a .lirc directory and .lircrc file. However in my experience it created a txt file .lirc and no .lircrc. I removed the txt file .lirc and created a directory .lirc and txt file .lircrc in my home account

$ mkdir .lirc
$ touch .lircrc

3: Ensure the remote/receiver is now working, in a terminal window:

$ irw <return>

Now press some buttons on the remote such as “Home” and “Play” and you should see the button codes | names | mceusb

4: Now cd into your .lirc directory and create these two files

$ touch irexec
$ touch irxevent

5: Edit the irexec and enter the following:

# Start XBMC
begin
prog = irexec
button = Home
config = ~/scripts/startXBMC.sh &
end

6: Make another directory in your home account called scripts

$ mkdir scripts

7: cd into this directory and make two files, one called startIRexec.sh & another called startXBMC.sh

8: Edit startXBMC.sh and enter the following:

#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
# if ps -ef|grep -v grep|grep -i mythfrontend.re
then
# Do nothing
echo “XBMC already Running!”
else
# Startup MythTV
xbmc
fi
exit

9: Edit startIRexec.sh and enter the following:

#!/bin/bash

# Test to see if IRXevent is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -i irxevent
then
ps aux|grep -i user_name|grep -i irxevent |awk ‘{print $2}’|xargs kill
else
# Do nothing
echo “irxevent already dead!”
fi

# Test to see if IRexec is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -vi start|grep -i irexec
then
ps aux|grep -i user_name|grep -i irexec |grep -vi start|awk ‘{print $2}’|xargs kill
else
# Do nothing
echo “irexec already dead!”
fi

#test to see if an instance of irxevent is already running
if ps -ef|grep -v grep|grep irxevent
then
# do nothing
echo “irxevent already running”
else
# start irxevent
irxevent ~/.lircrc &
fi

#test to see if an instance of irexec is already running
if ps -ef|grep -v grep|grep irexec
then
# do nothing
echo “irexec already running”
else
# start irxevent
irexec -d ~/.lircrc &
fi

exit

10: Edit the startIRexec.sh file and replace all user_name entries with your user name.

11: Make sure both scripts are executable:

$ chmod +x *.sh

12: Add the following lines to the .lircrc file in your home account

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

13: Manually execute the startIRexec.sh script

$ ~/scripts/startIRexec.sh

With any luck you should now be able to launch XBMC with the “Home” button on the MCE remote 🙂

To ensure that the irexec script starts when you login:

System > Preferences > Startup Application

The application to launch is /home/username/scripts/startIRexec.sh

Enjoy your new remote!

Advertisements

11 responses to this post.

  1. Posted by Kevin on June 17, 2010 at 2:56 am

    Nice, thanks. Skipped the first few steps as my Mythbuntu machine had lirc already installed. When executing the startIRexec script, it would output an error (awk: ^ invalid char ‘?’ in expression) and the Home button wouldn’t work. I rebooted and it worked without adding it in Startup Application. Perfect!

    Reply

  2. Posted by Jonathan on July 8, 2010 at 11:37 am

    Kevin, You need to replace the quotation marks in startIRexec.sh with actual single quotation marks. The ones you have copied and pasted have been formatted an are not valid characters.

    Reply

  3. Posted by Jonathan on July 8, 2010 at 11:38 am

    awk ‘{print $2}’ are the 2 offenders!

    Reply

  4. Posted by Kevin on February 4, 2011 at 3:55 am

    Thanks!! Wondering what your thoughts were but only received a followup (wordpress) email minutes ago about your July 8th post. Weird.

    Reply

  5. Posted by noods on February 4, 2011 at 4:14 am

    Hi Kevin, only just started blogging again after a big gap! Is your script still working? Did the comments from Jonathan work out for you?

    Reply

  6. Posted by deejayadhd on February 18, 2011 at 7:32 pm

    so i am trying to get this to work on mint9, replaced the quotes but still end up with errors and it dosent work… hope is ok to copy paste it,

    adhd@Hive1 ~/scripts $ ~/scripts/startIRexec.sh
    adhd 1853 1 0 14:22 ? 00:00:00 irxevent /home/adhd/.lircrc
    ERROR: garbage process ID “irxevent”.
    Usage:
    kill pid … Send SIGTERM to every process listed.
    kill signal pid … Send a signal to every process listed.
    kill -s signal pid … Send a signal to every process listed.
    kill -l List all signal names.
    kill -L List all signal names in a nice table.
    kill -l signal Convert between signal numbers and names.
    adhd 1858 1 0 14:22 ? 00:00:00 irexec -d /home/adhd/.lircrc
    ERROR: garbage process ID “irexec”.
    Usage:
    kill pid … Send SIGTERM to every process listed.
    kill signal pid … Send a signal to every process listed.
    kill -s signal pid … Send a signal to every process listed.
    kill -l List all signal names.
    kill -L List all signal names in a nice table.
    kill -l signal Convert between signal numbers and names.
    adhd 1853 1 0 14:22 ? 00:00:00 irxevent /home/adhd/.lircrc
    “irxevent already running”
    adhd 1858 1 0 14:22 ? 00:00:00 irexec -d /home/adhd/.lircrc
    “irexec already running”

    appreciate your sharing this, now only if i can get it to work. any ideas?

    Reply

    • Posted by noods on February 21, 2011 at 2:17 am

      Hi,

      Sorry not sure what the problem could be….I set this up on ubuntu so not sure if there are any differences between that and Mint 9…..might be worth emailing the guy above (Peter) as he has it working on mint 9 successfulyl!

      Cheers

      Lawrence

      Reply

  7. Posted by Peter on February 20, 2011 at 1:36 pm

    Thank you!
    This worked perfectly (I changed the quotes as Jonathan said before executing.)
    I started at mkdir .lirc as I already had my remote working.
    FYI I am running Linux Mint 9 with the lirc-source changes listed here:
    http://www.fscker.ca/rc/2010/04/27/mediagate-mg-ir01bk-and-ubuntu-9-10/

    Reply

  8. Posted by Tim on July 1, 2011 at 3:32 pm

    I had to install lirc-x package on my Ubuntu 11.04 but its working now!!! Thanks!

    Reply

  9. Posted by Chase on June 22, 2012 at 12:29 am

    Thanks man! I really appreciate you walking through this.

    Reply

  10. Thank you! I also got it working, using Xubuntu 12.04. However, I had to “sudo apt-get install lirc-x” in addition, and the button in “irexec” has to be “KEY_HOME” instead of “Home”. (but I chose “KEY_POWER”…)

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: