Thought I'd repost an answer to a question I gave to someone on the
mythtvtalk.com forums at
http://www.mythtvtalk.com/forum/viewtopic.php?t=542. It might be of
general interest to this group.
The question was regarding restarting the mythfrontend with a remote keypress.
Here's how I did it. I wrote a little perl script that runs in the
background and uses the Lirc::Client library to trap my remote
control's Power button. This causes mythfrontend to be killed and
restarted on DISPLAY :0. I'm sure it's not the most elegant solution,
but it works for my purposes.
To install the Lirc::Client library, assuming you have perl and the
cpan modules installed:
# /usr/bin/perl -MCPAN -e 'install "Lirc::Client"'
For info on using cpan, see www.cpan.org.
Here's my script that I run from my custom mythtv startup script. I
called it "restart-mythfrontend-IR" and I store it in /usr/local/bin.
The command I use to run it from my script is:
/usr/local/bin/restart-mythfrontend-IR > /dev/null 2>&1 &
You want it to run as the mythtv user so it can access DISPLAY=:0.
The perl script:
#!/usr/bin/perl
# Startup script for mythbackend
# Author: Larry Silverman
# Date : 1/15/2005
#
# description: A watcher for Power remote keypresses to restart mythfrontend.
# processname: restart-mythfrontend-IR
#
use Lirc::Client;
my $lirc = Lirc::Client->new('restart-mythfrontend-IR' , { # required
rcfile =>
"/home/mythtv/.mythtv/restart-mythfrontend-IR.lircrc", # optional
dev => "/dev/lircd", # optional
debug => 0, # optional
fake => 0, # optional
} );
my $code;
do { # Loop while getting ir codes
$code = $lirc->next_code; # wait for a new ir code
process( $code ); # do whatever you want with the code
} while( defined $code ); # undef will be returned when lirc dev exists
sub process($code) {
print "$code\n";
print "Killing mythfrontend\n";
system('killall mythfrontend');
print "Restarting mythfrontend\n";
$ENV{'DISPLAY'} = ':0';
system('mythfrontend > /dev/null 2>&1 &');
}
Put the code wherever you like, and be sure to make it executable:
# chmod 755 restart-mythfrontend-IR
The perl code references a file called restart-mythfrontend-IR.lircrc.
This is a lircrc file which maps a button on your remote to be caught
by the perl script. My .lircrc file contains:
begin
prog = restart-mythfrontend-IR
remote = grayHauppauge
button = Power
config = RestartMythTV
repeat = 3
end
I have a Hauppauge PVR-250, the grey and black remote and in my
/etc/lircd.conf file, the name of the power button is "Power". You'll
have to know the right string to put on the button line in your lircrc
file for your remote.
Good luck!
Larry
_______________________________________________
mythtv-users mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users