Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # make sure to set this string to
- # the corresponding remote in /etc/lircd.conf
- $remote_name = "RCA";
- # Let's assume you don't need to press enter after you punch in a
- # channel number. Change this to 1 if your cable box expects you press
- # enter after each command
- $needs_enter = 0;
- # Change this to point to your rc executable
- $rc_command = "/usr/bin/irsend";
- # This outputs debugging info to a file. Change path to suit your needs.
- $debugfile = "/tmp/debugchannelchange.txt";
- # This subroutine actually sends the signal to the cable box
- sub change_SIGNAL {
- my($SIGNAL) = @_;
- system ("$rc_command SEND_ONCE $remote_name $SIGNAL");
- }
- $SIGNAL=$ARGV[0];
- open F, ">> /var/log/channel.log";
- print F "channel changing $SIGNAL\n";
- close F;
- print "channel changing $SIGNAL\n";
- # Checks if $SIGNAL begins with a digit
- # If it detects that the string is made up of digits, then it puts
- # spaces between the digits. Ex. 1234 becomes 1 2 3 4
- if ( $SIGNAL =~ /^\d+$/ )
- {
- my $length = length($SIGNAL);
- my $counter = 0;
- my $temp;
- while( $counter < $length )
- {
- $temp .= substr($SIGNAL,$counter,1) ." ";
- $counter++;
- }
- # write out contents of $temp variable to a file for debugging
- # this has not been tested but should be close
- open (DEBUGCHANSCPT, ">>" . $debugfile); #open for write, append
- print DEBUGCHANSCPT "Timestamp: ";
- print DEBUGCHANSCPT ×tamp();
- print DEBUGCHANSCPT "\n";
- print DEBUGCHANSCPT "Channel String: ";
- print DEBUGCHANSCPT "$temp\n";
- change_SIGNAL($temp);
- }
- else
- {
- # argument we passed was not made up of digits, so it must be a
- # command that does something other than channel changing on the
- # cable box
- change_SIGNAL($SIGNAL);
- }
- # Do we need to send enter
- if ( $needs_enter )
- {
- system ("$rc_command SEND_ONCE $remote_name ENTER");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement