Change-channel-lirc.pl
From MythTV Official Wiki
Note: The correct title of this article is change-channel-lirc.pl. It appears incorrectly here due to technical restrictions.
| Author | Robert Kulagowski |
| Description | Simple script for changing the channel with a LIRC transmitter |
| Supports |
change-channel-lirc.pl is a simple script for changing the channel with a LIRC transmitter. This version can handle arbitrary-length channel numbers and includes some debugging output.
#!/usr/bin/perl
# Updated to handle arbitrary channel lengths, Robert Kulagowski, 2011-07-18
use Getopt::Std;
# make sure to set the remote_name string to
# the corresponding remote in /etc/lircd.conf
$remote_name = "directtv";
use constant false => 0;
use constant true => 1;
my $debugenabled = false;
my %options = ();
getopts( "dh", \%options );
if ( $options{h} ) {
print "usage: change-channel-lirc-v2.pl [-d] [-h] channum\n\n";
print "Parameter Meaning\n";
print "-d enable debug mode\n";
print "-h help (this screen)\n";
print "channum Integer channel number. Must be last parameter.\n";
exit(1);
}
if ( $options{d} ) { $debugenabled = true; }
my $channel = $ARGV[scalar(@ARGV)-1];
if ($debugenabled) { print "channel is $channel\n"; }
sleep 1;
for ($i = 0; $i < length($channel); $i++)
{
change_channel(substr($channel,$i,1));
}
# In the next command, check the /etc/lirc/lircd.conf file and confirm if
# your remote definition file uses "select" or "enter" or "ENTER" or whatever.
system ("irsend SEND_ONCE $remote_name select");
sub change_channel {
my($channel_digit) = @_;
if ($debugenabled) { print "Sending $channel_digit\n"; }
system ("irsend SEND_ONCE $remote_name $channel_digit");
sleep 1;
}
The following is the original version of this script:
#!/usr/bin/perl
# make sure to set this string to
# the corresponding remote in /etc/lircd.conf
$remote_name = "gi-motorola-dct2000";
sub change_channel {
my($channel_digit) = @_;
system ("irsend SEND_ONCE $remote_name $channel_digit");
sleep 1;
}
$channel=$ARGV[0];
sleep 1;
if (length($channel) > 2) {
change_channel(substr($channel,0,1));
change_channel(substr($channel,1,1));
change_channel(substr($channel,2,1));
} elsif (length($channel) > 1) {
change_channel(substr($channel,0,1));
change_channel(substr($channel,1,1));
} else {
change_channel(substr($channel,0,1));
}
system ("irsend SEND_ONCE $remote_name ENTER");