Tip #2: How to Customize MythTV's Menus

The fact that MythTV has so many features can be both a strength, and a weakness. With so many features, the menu structure can be quite difficult to navigate, and it's almost certain that there are some features you will *never* use.

Wouldn't it be nice to trim the MythTV menus to just what you use. Or, how about simply re-ordering them to suit your preferences? The good news is that you can, and quite easily.

First, a bit on how MythTV's menu system works.

The menu's are driven by XML files (located in /usr/share/mythtv/). Here is a snippet from the mainmenu.xml file:

<text>Watch TV</text>
<text lang="FR">Regarder la TV</text>
... [more languages snipped]

<text>Media Library</text>
<text lang="FR">Médiathèque</text>
... [more languages snipped]
<action>MENU library.xml</action>

The important parts are the menu title:
<text>Media Library</text>

and the action
<action>MENU library.xml</action>

There are two types of actions:

  1. link to another menu (MENU menuname.xml)
  2. launch an action (TV_WATCH_LIVE)

Needless to say, linking to another menu simply loads another menu XML file. Launching an action will run the MythTV feature that you select.

Don't start editing those files just yet! Let's run through an example and I'll show you how to safely go about editing the menus.

Example: Remove MythPhone and Netflix from Info Menu

Let's say that I never use MythPhone, or NetFlix, and I want to remove them from the Information menu. You might think.. "Hey, no problem, I'll just bring up /usr/share/mythtv/info_menu.xml up in my favorite editor (vi.. right?) and hack away!"

Nope... Once again, the MythTV devs have outdone themselves. You can make a local copy of the entire mythtv menu system in mythtv's home directory ~mythtv/.mythtv and when you fire up mythfrontend, it will read those files instead.

So.. go ahead..

$cp /usr/share/mythtv/*.xml ~mythtv/.mythtv

Just for reference, here is a quick screenshot of the offending menu (with MythPhone and NetFlix)

O.K. Now lets fire up vi and start editing your local copy of ~mythtv/.mythtv/info_menu.xml

Here is the menu entry for MythPhone

<action>PLUGIN mythphone</action>

Simply remove the section above (everything, including the <button> tags), and MythPhone will be removed from the menu.
Find the entry for NetFlix, and do the same.
Save the file, and re-run mythfrontend.

Viola, here's our new menu. sans MythPhone and NetFlix

As you can see, this process is quite simple.

Additional Notes:

Now, let's say MythTV upgrades to 0.20 and the devs add a new menu item. Unfortunately, you're custom menus won't be updated with the rest of MythTV, and this could leave you in a lurch. What I would recommend is making a diff file of your modified xml file with the original. Then after an upgrade, you should be able to re-apply your diff to the new menus. If you want to be safe, you can also diff your file with the new original and compare the two diff's, and handle the entire situation manually.

You can re-arrange any menu action and move it into any menu. You can create your own menus. One thing you can't do that I would love is to assign a shell action to a menu item.

UPDATE (6/17/2009):
As requested, here is an example of how I use MythTV's menu to launch Front Row (on the mac) and Hulu Desktop

<action>EXEC /Users/mythtv/bin/runfrontrow.sh</action>
<action>EXEC /Users/mythtv/bin/runhulu.sh</action>

Needless to say, I have scripts in my bin directory that actually execute the commands, but there you go.

Comments, Questions? Post 'em, I'll try and answer any question.

Coming up next: Transcoding profiles for HDTV folks.

Tip #1: MythTV's New Edit Keys Feature (0.19)

New to MythTV version 0.19 is the Edit Keys feature. As with any new feature in MythTV, there is little documentation on how to use it. I decided to take a look at it and see just how it works, and I was quite pleased with how easy and intuitive it was to use.

What is Edit Keys?

The Edit Keys screen allows you to remap any of the keyboard/remote control keys in all of the MythTV contexts. This includes jumppoints, TV Playback, Web Browsing, everything. It's quite powerful, and if you go too far, you can mess yourself up. Fortunately, if you try to re-map an already existing binding, the UI will warn you.

Update: As noted in mythtv-users you will need mythcontrols in order for the Edit Keys menu to be active.

Make a backup first

If you are uneasy about modifying your key bindings, then all you have to do is backup the keybindings table prior to making any changes.

$ mysqldump -p --host <hostname if remote> --databases mythconverg --table keybindings > keybindings.sql

And to restore:

$ mysql -p --host <hostname if remote> mythconverg < keybindings.sql

Let's see an example

O.K. Now that we've got that out of the way.. On to the example/tutorial. I use the Radio Shack 15-2116 remote (an awesome JP1 programmable remote), and one of my biggest pet peeves is the fact that the 'Select' key behaves differently between MythTV's internal player, and mplayer.

When viewing a video with mplayer, the 'Select' key toggles pause/play (nice!), and when viewing TV with MythTV's internal player the 'Select' key bookmarks the video. Toggle playback is done with the 'Pause' key instead. The 'Select' key is my favorite on this remote, because it's a big, fat, key right in the middle of the remote, and the 'Pause' key is small, and awkwardly placed towards the bottom.

This needs to be fixed. My goal here is to remap MythTV's internal TV Playback pause/play to the 'Select' key on my remote.

Edit Keys to the rescue!

From the main menu, select Utilities/Setup -> Edit Keys.

Figure 1: Edit Keys screen (click to enlarge).

The column on the left are all of the different contexts that can be configured. Each context can have its own keybindings.

For this example we'll just scroll down to the 'TV Playback' context.

Figure 2: Edit Keys screen - TV Playback (click to enlarge).

Moving to the right, and scroll down to the action you want to edit. In our case, that would be 'Pause' (which is really 'Toggle Play/Pause').

Figure 3: Edit Keys screen - Pause action selected (click to enlarge).

After selecting Pause, you drop down to the next open slot below. Note: each action can be assigned three keys.

Figure 4: Edit Keys screen - Next open slot (click to enlarge).

Next, we want to go ahead and add our new key assignment. Press enter (keyboard, or remote) and you will be prompted (Waiting for keypress):

Figure 5: Edit Keys screen - Waiting for keypress (click to enlarge).

Press the key on the remote (or keyboard) that you want to map to 'Pause'. In my case, this is the 'Select' key on my remote, which lirc defines to be the keyboard 'Return'.

Figure 6: Edit Keys screen - Add key 'Return'? (click to enlarge).

After accepting the new assignment, you may get a warning about conflicting with the global context, but that's just fine, because we are defining this key for just the TV Playback context.

Figure 7: Edit Keys screen - Global Context warning? (click to enlarge).

After selecting 'Bind Key', you will now see the new key binding in the slot on the bottom.

Figure 8: Edit Keys screen - Global Context warning? (click to enlarge).

That's IT! You now have a new key bound to the 'Pause' action. When you exit the screen, you'll be prompted to save your changes:

Figure 9: Edit Keys screen - Save Changes? (click to enlarge).
Select 'Yes' and you're off to the races!

If you have any questions, or comments, please be sure to leave them below.

Coming up next: Customizing MythTV Menus

Back up to: The 'Myth' of HDTV

Tags: ,

Introduction to MythTV Tips

Hello and welcome to MythTV Tips. I'm kicking off this blog after assembling several questions (both mine, and from others) about how to actually use MythTV. There are SOOOOO many features in MythTV, some documented well, and some.. not so much. I am going to use this site to publish my personal tips, tricks, tutorials for MythTV.

Feel free to comment with any questions you have, and I'll do my best to answer.
You can subscribe to MythTV Tips via RSS

Coming up: MythTV's new Edit Keys feature