source: npl/mediabox/lcdproc_edwin/src/clients/examples/x11amp.pl @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 1.7 KB
Line 
1#!/usr/local/bin/perl -w
2
3#
4# This is just a test!  It's simple, cheesy, and doesn't do much
5# or even look very nice.
6#
7# However, it demonstrates one way to handle input from the server.
8# (although it seems buggy..  oops!  :)
9#
10
11use IO::Socket;
12use Fcntl;
13
14# Connect to the server...
15$remote = IO::Socket::INET->new(
16                Proto     => "tcp",
17                PeerAddr  => "localhost",
18                PeerPort  => "13666",
19        )
20        || die "Cannot connect to LCDproc port\n";
21
22# Make sure our messages get there right away
23$remote->autoflush(1);
24
25sleep 1;        # Give server plenty of time to notice us...
26
27print $remote "hello\n";
28my $lcdconnect = <$remote>;
29#print $lcdconnect;
30
31
32# Turn off blocking mode...
33fcntl($remote, F_SETFL, O_NONBLOCK);
34
35
36# Set up some screen widgets...
37print $remote "client_set name {X11AMP test}\n";
38print $remote "screen_add x11amp\n";
39print $remote "screen_set x11amp name {X11AMP test}\n";
40print $remote "widget_add x11amp title title\n";
41print $remote "widget_set x11amp title {X11AMP test}\n";
42print $remote "widget_add x11amp one string\n";
43print $remote "widget_set x11amp one 1 2 {  <-: E ; F :->}\n";
44
45
46while(1)
47{
48        # Handle input...
49        while(defined($line = <$remote>)) {
50            @items = split(" ", $line);
51            $command = shift @items;
52            # Use input to change songs...
53            if($command eq "key")
54            {
55                $key = shift @items;
56                if($key eq "E")
57                {
58                    system("x11amp --rew");
59                }
60                if($key eq "F")
61                {
62                    system("x11amp --fwd");
63                }
64            }
65            # And ignore everything else
66            elsif($command eq "connect")
67            {
68            }
69            elsif($command eq "listen")
70            {
71            }
72            elsif($command eq "ignore")
73            {
74            }
75            else {
76                if($line =~ /\S/) {print "Huh?  $line\n";}
77            }
78        }
79
80        sleep 1;
81
82}
83
84close ($remote)            || die "close: $!";
85exit;
Note: See TracBrowser for help on using the repository browser.