In this howto I will explain how I managed to control the MythFrontend with the multimedia keys of my keyboard. Since my ir-remote is always everywhere but at my pc, I wanted a way to start playing music, skip a song... without getting my lazy ass off the chair to get my remote . Little problem, I cannot focus the frontend, because it is running on my second screen and I patched my wm (xfwm4), so it doesn't touch it.
The solution, I came up with, will even work, if the frontend is running on another machine in your network! It is also WM independent, because we will use xhkeys to assign commands to your keyboard.

Let's get started then!

At first we have to enable the MythFrontend's control via telnet. It's in Settings -> General -> General (Enable Network Remote Control Interface). After that, we are able to telnet into the frondend and send commands to it. Here is some documentation about it.

Now we need a script that connects with telnet, sends a command and exits, when we call it. I did some googleing and the only working solution for automating telnet requests, I came up with, was with a little tool called expect.
Let's install it:

(Note: You should adjust the host and port vars to where the frontend is running.)

I called it ~/.mythtv/mythremote and made it executable

Code:

$ chmod +x ~/.mythtv/mythremote

So, let's test it. Start mythmusic with some songs in the playlist and do:

Code:

$ ~/.mythtv/mythremote key greater

If it works, it should have skipped to the next song.

Now we will assign controls to keyboard keys.
Therefore I use a little tool called xhkeys, because it makes me independent of the WM i'm using and is able to even use unbound keys, like the multimedia keys of my BenQ keyboard. It also has a little OSD, showing you the command it is performing.

Code:

# emerge -av xhkeys

Start the config tool

Code:

$ xhkconf

press a key or combination and select [2] for command type "Application".
As shell command we now use our "mythremote" script.