[mythtv-users] Run a program from a key?

R. G. Newbury newbury at mandamus.org
Tue Feb 7 02:23:39 UTC 2012

On 02/06/2012 04:47 PM, Kris B. wrote:
> On Mon, Feb 6, 2012, at 04:27 PM, Tom Lichti wrote:
>> What desktop manager are you running? Most of them have a facility to
>> remap keys, or go lower level and use xbindkeys.
>> Tom
> I never even thought of that.  Running Mythbuntu/XFCE, so I am sure I
> can do that.  Great... I will be using even less power (though longer
> startups, I guess :) )
> Thanks!

I think this will depend on exactly how your remote 'talks' to the 
computer. Rob Longbottom's reply works for a lirc connection. It's what 
I use.

But this can work using xbindkeys if your remote emulates a keyboard 
directly (as it sounds like it does with the dongle). It really depends 
on whether the remote/computer combo will stay 'awake' enough to respond 
to a 'wake up'.

I just tried a quick experiment.
1) you might need to install xbindkeys first!

2) use xev to find the state and keycode of a little used key which you 
want to re-map. For this I used the PrtSc (PrintScreen key) on my laptop.

xev says PrtSc has a 'state' of 0x0 and keycode of 170

3) I created a .xbindkeysrc file in /home/user with xbindkeys --defaults 
 > /home/user/.xbindkeysrc

4) I added this to the bottom of .xbindkeysrc:

    c:107 + m:0x0

5) The executable file 'junk' contains only:
/usr/bin/mplayer /usr/share/sounds/Kopete_Event.ogg
(Plays a sound when it runs.)

6) Then 'xbindkeys &' in a console
7) I pressed 'PrtSc' and got sounds!

If you add 'xbindkeys' to either ~/.xinitrc, or call 'xbindkeys &' in 
rc.local, it will do the binding on every boot.

8) You might want to try something like this script. I map 
'mythpowerbutton.sh' to a key on my IR remote using irexec and lircrc as 
first mentioned. It toggles mythfrontend, starting or killing it when 
pressed, depending on what a grep of the output of 'ps' finds. For your 
use, you can substitute a command to shut things down/start up.

Useful for clearing hangs or other problem states from the 
remote...instead of ssh-ing in from the laptop.
(What? Couch-potato? Naaah...Pass the chips!)

# check for running mythfrontend
STATUS=`ps -ae | grep mythfrontend | grep -v grep | wc -l | awk '{print 
# check for proper Display so it only runs on the correct frontend
count=`echo $DISPLAY | grep ":0" | wc -l `

export STATUS
if [ $STATUS -eq 0 ];
         # Start mythfrontend
         /usr/bin/mplayer /usr/share/sounds/KDE-Im-Contact-In.ogg
         /usr/local/bin/mythfrontend --display $DISPLAY -v playback -l 
/var/log/mythfrontend.log &
         sleep 3
         killall startfrontend.sh;
        # kill all running mythfrontends
         /usr/bin/mplayer /usr/share/sounds/Kopete_Event.ogg
         killall mythfrontend
         killall startfrontend.sh;
exit 0





More information about the mythtv-users mailing list