summaryrefslogtreecommitdiff
path: root/additions/SW/usb-ir-toy-lirc/send
blob: f0f7a1e0771fc80c9de6d8da3a8a961a6bd9ecfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl 
use strict;
use warnings;
use 5.016;
use Time::HiRes 'sleep';
 
my @cmds;
 
open my $fh,'<','/etc/lirc/lircd.conf';
while (my $line=<$fh>) {
    $line =~ m{^\s+(b[123]\w+)} or next;
    push @cmds,$1;
}
 
while (@cmds) {
    my $current = shift @cmds;
    say "Ready to send $current";
    my $ans=<>;
    if ($ans =~ m{^a}) {
        unshift @cmds,$current;
        $current=pop @cmds;
        unshift @cmds,$current;
        redo;
    }
    elsif ($ans =~ m{^n}) {
        push @cmds,$current;
        next;
    }
    system('irsend','SEND_START','sonic',$current);
    sleep 0.8;
    system('irsend','SEND_STOP','sonic','');
    push @cmds,$current;
}