Total IR Control for Linux
Home arrow Your Project arrow Popular Uses arrow DIY Smart Remote arrow Step-by-Step HOWTO
HOWTO: Make any Remote better than Harmony
Article by Matthew Bodkin, CommandIR Engineer and Support 2004-2008
Published: July 5th, 2008 in preparation for the upcoming CommandIR II!
Return to Background and Introduction

Howto by Example

The videos and photos below show a simple demonstration of this concept - integrating seamless VCR control into MythTV.  It is fully meant to be extended to control whatever external devices you may have, including:

  • Your Game consoles
  • Your HD equipment, perhaps bypassing your PC
  • Your Legacy devices - VCR, DVD, Videodisc, OTA Radio, Cassette tape desk
  • Your Satellite radio receivers
  • Anything else with a remote control

It's a huge pain to come up with all of this from scratch, so I've posted a the fully working solution shown in the videos.  They should be a good starting point - more devices/tasks can easily be added just by copying the samples.

Now let's have a look at the files and hardware used for the demo.

My work test devices are: 

A/V Gear

  • 1 Samsung TV
  • 1 Philips VCR
  • 2 Fortec Star set-top boxes
[Download lircd.conf]


  • MythBuntu 8.04, patched to support CommandIR II
  • Videos recorded with Hauppauge PVR-250
  • Demo shows "smarting up" the original Hauppauge remote

IR  Transceiver

  • CommandIR II used with 4 IR emitters and using built-in receiver
  • Note: This setup guide can be applied to any LIRC compatible hardware

Step 1: Get Remote Codes for Remotes and Devices

Find or record the remotes codes for the remote you want to use and all the devices you want to control if you do not already have them. See the Setup LIRC Remote Codes guide for more info.

Step 2: Focus Changing Use To & From Scripts

Let the PC 'press' all the other remotes for you to switch your TV focus to another device
Switch to MythTV on your target display, then manually use your remotes to change the focus to the target device and note the devices and order you use.

Make and scripts containing these commands to switch focus to and from your external device.  Eg, pressing "Aux3" on the TV remote to switch to your game console video output, and "Aux3" on your audio receiver to hear your game console output.  Repeat for as many tasks/devices you wish to add.

In my example, the PC uses the Front Input (pressing 'tvvideo') and the VCR uses coax on channel 3. I also send 'play' to the VCR since 99% of the time I would have already put a video in:

#  - Commands to switch from PC input to VCR on channel 3
# CommandIR version
irsend send_once commandir settransmitters-1
irsend send_once samsung_tv tvvideo 0 3
irsend send_once commandir settransmitters-2
irsend send_once philips_vcr play
irexec /home/matt/control/lircrc-vcr
The final irexec line will be used in the next section to effectively "translate" the Hauppauge remote commands receive into VCR commands to be sent to the VCR.

If you're not using CommandIR you can omit the 'commandir' lines of course which simply select which transmitter to send the command on. In this example, the TV is using emitter #1 and the VCR is using emitter #2. Similarly, a script should switch your focus back to MythTV - eg, pressing "VGA" on the TV remote if you connect via VGA connector. Switching this simple TV back to the Video line is quite simple:

#  - Commands to switch from VCR focus back to PC/MythTV on video-in AUX
irsend send_once commandir settransmitters-1
irsend send_once samsung_tv tvvideo
irsend send_once commandir settransmitters-2
irsend send_once philips_vcr stop
killall irexec

Create similar files for any other devices you want to be able to switch to from MythTV.

Rewinding the VCR video
Step 3: Remote Translator

Next we replace the remotes for each device by getting LIRC to 'translate' by converting commands received from your PC remote to the corresponding command the device will understand. ie: pressing 'play' on your remote sends 'play' to your device.

Important Note!
In this demo setup, I need the media control commands (play, stop, pause, ff, rew, rec) to control the VCR, but I want the volume commands (vol+, vol-) to change the volume on the TV's speakers. 

So my remote mapping will be:

Remote Mapping for Demo System
PC Remote Button Maps to Target Device Command
Hauppauge Play -> Philips_vcr Play
Hauppauge Pause -> Philips_vcr Pause
Hauppauge Stop -> Philips_vcr Stop
Hauppauge Ffw -> Philips_vcr Ff
Hauppauge Rew -> Philips_vcr Rew
Hauppauge Vol+ -> Samsung_tv Vol+
Hauppauge Vol- -> Samsung_tv Vol-

Create your lircrc-task file to implement this mapping using a number of stanza's like this:
 prog = irexec
 remote = hauppauge
 button = play
 repeat = 0
 config = /home/matt/control/ 2 philips_vcr play
# repeat>0 for volumes - we DO want to be able to hold the vol buttons
prog = irexec
remote = hauppauge
button = vol+
repeat = 3
config = /home/matt/control/ 1 samsung_tv vol+

# Two ways to get back to the main menu
prog = irexec
remote = hauppauge
button = back/exit
repeat = 0
config = /home/matt/control/
prog = irexec
remote = hauppauge
button = menu
repeat = 0
config = /home/matt/control/

Make sure you have a way to run your script which will return you to MythTV - shown in the final stanzas above.

As you can see, irexec runs whatever command is in the 'config =' line.  Since multiple commands are often needed, I use a script like this:
#  for CommandIR
irsend send_once commandir settransmitters-$1
irsend send_once $2 $3

Step 3.5: Try it so Far

To test this out before adding to MythTV, simply run your script:
mythtv@mediabox:~/control$ ./ 
Your TV should switch to the correct input, and your remote translator should start so you can control that device from whatever remote is setup.

Step 4: Power-button Support (Optional)

I use a simple '' script that is the same for powering on and off these devices.  It should be added as an irexec event in a ' ' file that will run in MythTV mode:

# TO MAIN - ie start-up script for any irexec functions available while viewing the MythTV menu
# Important to have '&' at the end of the irexec!  Want it to return control to MythTV!
irexec /home/matt/control/lircrc-mythtvmenu &
And MythTV's own custom lircrc for irexec called lircrc-mythtvmenu :
 prog = irexec
 remote = hauppauge
 button = power
 repeat = 0
 config = /home/matt/control/
The script is exactly what you'd expect - send the 'power' command to any devices you want powered on/off from your main remote:

# - Toggle power on all devices
irsend send_once commandir settransmitters-2
irsend send_once philips_vcr power
irsend send_once commandir settransmitters-1
irsend send_once samsung_tv power
irsend send_once commandir settransmitters-3
irsend send_once fortec_stb power
irsend send_once commandir settransmitters-4
irsend send_once fortec_stb power
You may not want to power off any set-top boxes used for MythTV recordings.  Don't forget to add to a start-up script so it starts when your PC boots up since you probably want it running without selecting 'power' from the menu.

Step 5: Add to MythTV Menu

Triggering your scripts from MythTV is very easy since menus are stored in an XML format in /usr/share/mythtv/.  I added these lines to mainmenu.xml:

     <text>Watch VHS Video</text>
     <action>EXEC /home/matt/control/</action>
     <text>Switch to XBOX</text>
     <action>EXEC /home/matt/control/</action>

A front-end restart is required to reload the menus.


Demo Videos

Sample configuration files in action on my office test gear.

Total Power Control

Powers off 2 set-top boxes, the TV and VCR.

Blink and you'll miss it - powering off all devices in an entertainment system has never happened faster. 4 devices powered-off at once using CommandIR II.

MythTV Integration I

  • MythTV Menu Integration
  • Select 'Watch VHS'
  • Volume adjusted on TV
  • Play/stop commands send to VCR
  • Return to MythTV
  • Power-off System
These videos have no sound.

MythTV Integration II

  • Power-on all Devices
  • Select 'Watch VHS'
  • Volume keys translated to TV
  • Play/Stop/Rewind/Play commands translated to VCR
  • Return to MythTV
  • Power-off System
These videos have no sound.


Summary and Demo Files

In summary, for each task/device mode create:

  •  - containing commands to switch focus from TV/PC to that device
  • - commands to switch back to TV/PC
  • lircrc-task - remote translator to blast commands the device understands based on commands detected from your PC remote


Full versions of all the above files can be downloaded:

The paths all have a hardcoded '/home/matt' home directory that would have to be changed to your own user name (or just cheat by adding a simlink).


If you've been looking for a way to pack up all your extra remotes for a fun weekend project, I hope you'll find this one worthwhile! It's been a great solution for me for a couple years so I hope it will for you too.

Simplify this a bit: 

You can simplify some of the tediousness of these configuration files by using our LIRC Config online tool.  Sign-in and look under 'Automation Tools' for a script generator and remote translator features.
We have a new completely redesigned AJAX-based LIRC Config in the works - just create an account and I'll email when the new one's up. 

AddThis Social Bookmark Button
Last Updated: Saturday, 05 July 2008

CommandIR Control Technologies is a division of InnovationOne Applied Technology.

(C) 2006-2012, All Rights Reserved. 

Last update: Mon Oct 29 22:23:04 EDT 2012


Privacy   Terms of Use