Files
lcdproc/clients/examples/x11amp.pl
T
William Ferrell 6dabd0b8f3 Applied patches supplied by Andre' Breiler:
- bugfixes for display != MatrixOrb LCD
	- changes the meaning of output_state
		+ it's now a bitfield where evry bit corresponds to
		  one output
	- protocol change
		output on|off|value
		where on    = all outputs on
		      off   = all outputs off
		      value = output on for all 1 bits
	- changes the behavior for key presses
	  Keypresses are now deliverd to _all_ clients (not only
	  the one with the active screen)
	reason: I have an client which is only active a few seconds after
                an keypress
	- changes the protocol so that a response is sent for every
	  command
	reason: the client needs to communicate with the server with a
                minimal latency
2001-03-22 22:51:49 +00:00

89 lines
1.8 KiB
Prolog
Executable File

#!/usr/local/bin/perl -w
#
# This is just a test! It's simple, cheesy, and doesn't do much
# or even look very nice.
#
# However, it demonstrates one way to handle input from the server.
# (although it seems buggy.. oops! :)
#
use IO::Socket;
use Fcntl;
# Connect to the server...
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => "13666",
)
|| die "Cannot connect to LCDproc port\n";
# Make sure our messages get there right away
$remote->autoflush(1);
sleep 1; # Give server plenty of time to notice us...
print $remote "hello\n";
my $lcdconnect = <$remote>;
#print $lcdconnect;
# Turn off blocking mode...
fcntl($remote, F_SETFL, O_NONBLOCK);
# Set up some screen widgets...
print $remote "client_set name {X11AMP test}\n";
print $remote "screen_add x11amp\n";
print $remote "screen_set x11amp name {X11AMP test}\n";
print $remote "widget_add x11amp title title\n";
print $remote "widget_set x11amp title {X11AMP test}\n";
print $remote "widget_add x11amp one string\n";
print $remote "widget_set x11amp one 1 2 { <-: E ; F :->}\n";
while(1)
{
# Handle input...
while(defined($line = <$remote>)) {
@items = split(" ", $line);
$command = shift @items;
# Use input to change songs...
if($command eq "key")
{
$key = shift @items;
if($key eq "E")
{
system("x11amp --rew");
}
if($key eq "F")
{
system("x11amp --fwd");
}
}
# And ignore everything else
elsif($command eq "connect")
{
}
elsif($command eq "listen")
{
}
elsif($command eq "ignore")
{
}
elsif($command eq "success")
{
}
else {
if($line =~ /\S/) {print "Huh? $line\n";}
}
}
sleep 1;
}
close ($remote) || die "close: $!";
exit;