Configuring Your MCE IR Remote

February 9th, 2009

You can use the keyboard to control absouletly everything in MythTV but it’s not that practical once the lights are out and you’re mid movie. So one of the first things I was looking to do is get my Microsoft MCE remote working just the way I wanted.

For some background info you might want to check out the MCE Remote section of the MythTV wiki here.

MythTV does a pretty good job of setting up some defaults for the buttons but, if like me you’ve come from a Windows MCE system you may fine the lirc config files and associated script below useful.

These configs do four things above the functionality MythTV provides out of the box:

  1. Start / Restart mythfrontend when “the big green button” is pressed (handy if the frontend ever misbehaves)
  2. Cycle through subtitles when watching TV or movies in mplayer
  3. Make the Red button behave as expected for interactive TV. Green, Yellow, Blue and Teletext also act as they should.
  4. Make other buttons behave as a Windows MCE user would expect.

Here’s how all the buttons will function once everything is set up:

MCE Remote Mappings

MCE Remote Mappings


Girlfriend proof it

A small tip which helps with the gf factor is removing the exit and shutdown menu when the back button is pressed from the main menu. To do this, in the frontend go to “Utilities / Setup” -> “Setup” -> “General”. Go to the fourth screen with the title of  “General” and change the “System Exit Key” to “No exit key”. You can always exit the frontend with “alt F4″ if you need to.

Bash script to start / restart the frontend

The first thing to do is setup the bash script which will start or restart the MythTV frontend application when the big green button on your remote is pressed. Copy the script below and put it in a new file in your home directory.  I put mine in ~/mythtv/runmyth

#!/bin/sh
RUNNING=0;
 
for x in `ps -C mythfrontend.re | grep -v PID` end; do
    test $x != 'mythfrontend.re' && continue
    RUNNING=1;
done
 
if [ $RUNNING = 1 ]; then
  #kill the process
   kill -9 `ps -aef | grep 'mythfrontend.re' | grep -v grep | awk '{print $2}'`
  #start it up again
  `mythfrontend &`
else
  `mythfrontend &`
fi

Don’t forget to make it executable

chmod 777 runmyth

lirc config files
Now that’s out the way here follows the lirc files for MythTV and mplayer. They should go into ~/.lirc/mythtv and ~/.lirc/mplayer respectively. Make sure the runmyth script path is defined correctly on line four of the mythtv lirc file.

mythtv

begin
    prog = irexec
    button = Home
    config = /home/colin/mythtv/runmyth &;
end
 
begin
    remote = mceusb
    prog = mythtv
    button = LiveTV
    config = %
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = RecTV
    config = ;
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = DVD
    config = m
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Red
    config = F2
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Green
    config = F3
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Yellow
    config = F4
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Blue
    config = F5
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Teletext
    config = F6
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Clear
    config = w
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Star
    config = T
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Record
    config = R
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Seven
    config = 7
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Right
    config = Right
    repeat = 3
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Mute
    config = |
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Skip
    config = Right
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = One
    config = 1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Down
    config = Down
    repeat = 3
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Zero
    config = 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Replay
    config = Left
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Pause
    config = P
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Six
    config = 6
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Two
    config = 2
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = ChanDown
    config = Down
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = ChanUp
    config = Up
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Rewind
    config = <
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Forward
    config = >
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Play
    config = P
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = VolDown
    config = [
    repeat = 1
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Stop
    config = Escape
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Back
    config = Escape
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = VolUp
    config = ]
    repeat = 1
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Five
    config = 5
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = More
    config = I
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Four
    config = 4
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = OK
    config = Return
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Up
    config = Up
    repeat = 3
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Nine
    config = 9
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Three
    config = 3
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Enter
    config = Enter
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Eight
    config = 8
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Guide
    config = S
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mythtv
    button = Left
    config = Left
    repeat = 3
    delay = 0
end

mplayer

begin
    remote = mceusb
    prog = mplayer
    button = Play
    config = pause
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Star
    config = sub_select
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Blue
    config = audio_delay 0.1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Yellow
    config = audio_delay -0.1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = ChanDown
    config = panscan -0.1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = ChanUp
    config = panscan +0.1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Pause
    config = pause
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = OK
    config = pause
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Power
    config = quit
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Mute
    config = mute
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = VolDown
    config = volume -1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Skip
    config = seek +15 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Enter
    config = pause
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Stop
    config = quit
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Up
    config = seek +60 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = VolUp
    config = volume +1
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Down
    config = seek -60 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Replay
    config = seek -15 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Right
    config = seek +6 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Rewind
    config = seek -30 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Forward
    config = seek +30 0
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Home
    config = vo_fullscreen
    repeat = 0
    delay = 0
end
 
begin
    remote = mceusb
    prog = mplayer
    button = Left
    config = seek -6 0
    repeat = 0
    delay = 0
end

Tags: , , , ,

7 Responses to “Configuring Your MCE IR Remote”

  1. Menny says:

    Great, I’m gonna use this one :)

    I found the default MCE remove configuration of MythTV quite basic, and tried to add some stuff, e.g., the subtitles.
    But I prefered the use the “big green button” for starting only, and the power button for exit (I’ve changed the “System Exit Key” to alt+ESC, and configured the remote’s power button to it.).

    BTW, how about adding this one to MythTV svn?

  2. Menny says:

    BTW, I like the “repeat” settings.
    This is quite an improvement over the default lirc configuration.

  3. Andrew says:

    Nice work.

    The one thing I cant seem to get to work is direct access of the Recorded TV screen from LiveTV. The Key mapping below does not seem to work for me;

    begin
    remote = mceusb
    prog = mythtv
    button = RecTV
    config = ;
    repeat = 0
    delay = 0
    end

    Any ideas as to why the above does not work?

    All the best

    Andrew

  4. Abongile says:

    I am completely new to linux. I followed the instructions: copied the files as per in the instructions, including making runmythtv executable. However I don’t know how check that mythtv is using the new lirc files or how to point it to them. Could I have put them in wrong place (/etc/lirc/mythtv and /etc/lirc/mplayer)? I see that lirc is also in /usr/share/lirc. I apologise if this is not the right place to ask. Please help!

  5. colin says:

    @Abongile the files need to go into the .lirc folder in your home directory on a standard MythBuntu install. So ~/.lirc/mythtv and ~/.lirc/mplayer
    You will need to restart the machine or lirc for the new config files to take affect.
    Hope this helps.

  6. colin says:

    @Andrew have checked this out and it does not work on my config either. I can’t say I use it that often but I thought I had it going. Had a quick play around but can’t seem to find the MythTV lirc config skip to this jump point. Will update the post once I have figured it out.

  7. Abongile says:

    @Colin, I am completely new to linux, so to me home directory is understood as / (root) and the folder as /home but in either case I do not immediately have an lirc folder/directory. The whereis ~/.lirc command gives me everything from linux-headers to man file locations. For good measure I tried placing them in /usr/share/lirc (/mythtv and /mplayer) respectively and moved the runmythtv file from /home/mythtv to /usr/share/mythtv/runmythtv, rebooted and no luck.

    I need an even more basic guide e.g. 1) “your home directory is /home/abongile”, 2) cp the files (mythtv and mplayer) from /usr/share/lirc and the runmythtv file to /? 3) rm the files from the other locations 4) reboot 5)Press big green button on MCE remote model 1039 and you should get…. something along these lines would really help.

    PS thank for the reply getting responses is very encouraging at what is often a very frustrating experience as it still quiet a learning curve adopting linux.

Leave a Reply