Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # make sure to set this string to
  4. # the corresponding remote in /etc/lircd.conf
  5. $remote_name = "RCA";
  6.  
  7. # Let's assume you don't need to press enter after you punch in a
  8. # channel number. Change this to 1 if your cable box expects you press
  9. # enter after each command
  10. $needs_enter = 0;
  11.  
  12. # Change this to point to your rc executable
  13. $rc_command = "/usr/bin/irsend";
  14.  
  15. # This subroutine actually sends the signal to the cable box
  16. sub change_SIGNAL {
  17. my($SIGNAL) = @_;
  18. system ("$rc_command SEND_ONCE $remote_name $SIGNAL");
  19. }
  20.  
  21. $SIGNAL=$ARGV[0];
  22. open F, ">> /var/log/channel.log";
  23. print F "channel changing $SIGNAL\n";
  24. close F;
  25. print "channel changing $SIGNAL\n";
  26.  
  27. # Checks if $SIGNAL begins with a digit
  28. # If it detects that the string is made up of digits, then it puts
  29. # spaces between the digits. Ex. 1234 becomes 1 2 3 4
  30. if ( $SIGNAL =~ /^\d+$/ )
  31. {
  32. my $length = length($SIGNAL);
  33. my $counter = 0;
  34. my $temp;
  35.  
  36. while( $counter < $length )
  37. {
  38. $temp .= substr($SIGNAL,$counter,1) ." ";
  39. $counter++;
  40. }
  41.  
  42. change_SIGNAL($temp);
  43. }
  44. else
  45. {
  46. # argument we passed was not made up of digits, so it must be a
  47. # command that does something other than channel changing on the
  48. # cable box
  49. change_SIGNAL($SIGNAL);
  50. }
  51.  
  52. # Do we need to send enter
  53. if ( $needs_enter )
  54. {
  55. system ("$rc_command SEND_ONCE $remote_name ENTER");
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement