apllied Jarda Benkovsky's perl clients patch
This commit is contained in:
+40
-18
@@ -1,20 +1,53 @@
|
||||
#!/usr/local/bin/perl -w
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
#
|
||||
# This LCDproc client takes a list of machines to ping and and reports
|
||||
# number of those which ping and number of those which do not and their list
|
||||
#
|
||||
|
||||
############################################################
|
||||
# Configurable part. Set it according your setup.
|
||||
############################################################
|
||||
|
||||
# Host which runs lcdproc daemon (LCDd)
|
||||
$HOST = "localhost";
|
||||
|
||||
# Port on which LCDd listens to requests
|
||||
$PORT = "13666";
|
||||
|
||||
# Path to `ping' command
|
||||
$PING = "ping";
|
||||
|
||||
# list of hosts to be ping'ed
|
||||
@MACHINES = ("lcdproc.omnipotent.net",
|
||||
"www.linux.org",
|
||||
"www.daemonnews.org",
|
||||
"127.0.0.1",
|
||||
"seurat",
|
||||
"rodin",
|
||||
"matisse",
|
||||
);
|
||||
|
||||
############################################################
|
||||
# End of user configurable parts
|
||||
############################################################
|
||||
|
||||
|
||||
# Connect to the server...
|
||||
$remote = IO::Socket::INET->new(
|
||||
Proto => "tcp",
|
||||
PeerAddr => "localhost",
|
||||
PeerPort => "13666",
|
||||
PeerAddr => $HOST,
|
||||
PeerPort => $PORT,
|
||||
)
|
||||
|| 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...
|
||||
sleep (1); # Give server plenty of time to notice us...
|
||||
|
||||
print $remote "hello\n";
|
||||
my $lcdconnect = <$remote>;
|
||||
@@ -43,26 +76,15 @@ while(1)
|
||||
#print "Main loop...\n";
|
||||
# Handle input... (just spew it to the console)
|
||||
while(defined($line = <$remote>)) {
|
||||
if ( $line =~ /^success$/ ) next;
|
||||
if ( $line =~ /^success$/ ) { next; }
|
||||
print $line;
|
||||
}
|
||||
|
||||
undef %down;
|
||||
undef %up;
|
||||
foreach $machine ("ZakaZak",
|
||||
"webfoot",
|
||||
"degas",
|
||||
"cassat",
|
||||
"miro",
|
||||
"monet",
|
||||
"dali",
|
||||
"escher",
|
||||
"seurat",
|
||||
"rodin",
|
||||
"matisse",
|
||||
)
|
||||
foreach $machine (@MACHINES)
|
||||
{
|
||||
`ping -c 1 $machine`;
|
||||
`$PING -c 1 $machine`;
|
||||
if($?) { $down{$machine} = 1; }
|
||||
else { $up{$machine} = 1; }
|
||||
}
|
||||
|
||||
+36
-15
@@ -1,8 +1,36 @@
|
||||
#!/usr/local/bin/perl -w
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# This client for LCDproc displays the tail of a specified file.
|
||||
# It's possible to change the visible part of the file with LCDproc
|
||||
# controlled keys
|
||||
#
|
||||
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
############################################################
|
||||
# Configurable part. Set it according your setup.
|
||||
############################################################
|
||||
|
||||
# Host which runs lcdproc daemon (LCDd)
|
||||
$HOST = "localhost";
|
||||
|
||||
# Port on which LCDd listens to requests
|
||||
$PORT = "13666";
|
||||
|
||||
# These define the visible part of the file...
|
||||
$top = 3; # How far from the end of the file should we start?
|
||||
$lines = 3; # How many lines to display?
|
||||
$left = 1; # Left/right scrolling position,
|
||||
$width = 20; # and number of characters per line to show
|
||||
|
||||
############################################################
|
||||
# End of user configurable parts
|
||||
############################################################
|
||||
|
||||
$slow = 1; # Should we pause after the current frame?
|
||||
|
||||
if($#ARGV < 0)
|
||||
{
|
||||
print "Usage: tail.pl file\n";
|
||||
@@ -14,8 +42,8 @@ $filename = shift @ARGV;
|
||||
# Connect to the server...
|
||||
$remote = IO::Socket::INET->new(
|
||||
Proto => "tcp",
|
||||
PeerAddr => "localhost",
|
||||
PeerPort => "13666",
|
||||
PeerAddr => $HOST,
|
||||
PeerPort => $PORT,
|
||||
)
|
||||
|| die "Cannot connect to LCDproc port\n";
|
||||
|
||||
@@ -34,7 +62,7 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
||||
|
||||
|
||||
# Set up some screen widgets...
|
||||
print $remote "client_set name {Tail ($filename)}\n";
|
||||
print $remote "client_set name {Tail}\n";
|
||||
print $remote "screen_add tail\n";
|
||||
print $remote "screen_set tail name {Tail $filename}\n";
|
||||
print $remote "widget_add tail title title\n";
|
||||
@@ -44,13 +72,6 @@ print $remote "widget_add tail 2 string\n";
|
||||
print $remote "widget_add tail 3 string\n";
|
||||
|
||||
|
||||
# These define the visible part of the file...
|
||||
$top = 3; # How far from the end of the file should we start?
|
||||
$lines = 3; # How many lines to display?
|
||||
$left = 1; # Left/right scrolling position,
|
||||
$width = 20; # and number of characters per line to show
|
||||
|
||||
$slow = 1; # Should we pause after the current frame?
|
||||
|
||||
# Forever, we should do stuff...
|
||||
while(1)
|
||||
@@ -58,7 +79,7 @@ while(1)
|
||||
# Handle input... (spew it to the console)
|
||||
# Also, certain keys scroll the display
|
||||
while(defined($input = <$remote>)) {
|
||||
if ( $input =~ /^success$/ ) next;
|
||||
if ( $input =~ /^success$/ ) { next; }
|
||||
print $input;
|
||||
|
||||
$slow = -10;
|
||||
@@ -103,9 +124,9 @@ while(1)
|
||||
}
|
||||
else # If the file is unreadable, show an error
|
||||
{
|
||||
print $remote "widget_set tail one 1 2 {$filename}\n";
|
||||
print $remote "widget_set tail two 1 3 {doesn't exist.}\n";
|
||||
print $remote "widget_set tail three 1 4 { }\n";
|
||||
print $remote "widget_set tail 1 1 2 {$filename}\n";
|
||||
print $remote "widget_set tail 2 1 3 {doesn't exist.}\n";
|
||||
print $remote "widget_set tail 3 1 4 { }\n";
|
||||
}
|
||||
|
||||
# And wait a little while before we show stuff again.
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/local/bin/perl -w
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# Simple client for LCDproc which controls XMMS/X11AMP MP3 player
|
||||
# from the keyboard controlled by LCDproc. It can only rewind to
|
||||
# previous song and skip forward to previous one.
|
||||
#
|
||||
# This is just a test! It's simple, cheesy, and doesn't do much
|
||||
# or even look very nice.
|
||||
@@ -11,11 +15,32 @@
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
############################################################
|
||||
# Configurable part. Set it according your setup.
|
||||
############################################################
|
||||
|
||||
# Host which runs lcdproc daemon (LCDd)
|
||||
$HOST = "localhost";
|
||||
|
||||
# Port on which LCDd listens to requests
|
||||
$PORT = "13666";
|
||||
|
||||
# Path to command which controls XMMS/X11AMP
|
||||
$XMMS = "xmms";
|
||||
|
||||
# Commands to set to previous / next song
|
||||
$XMMS_FORWARD = "$XMMS --fwd";
|
||||
$XMMS_REWIND = "$XMMS --rew"
|
||||
|
||||
############################################################
|
||||
# End of user configurable parts
|
||||
############################################################
|
||||
|
||||
# Connect to the server...
|
||||
$remote = IO::Socket::INET->new(
|
||||
Proto => "tcp",
|
||||
PeerAddr => "localhost",
|
||||
PeerPort => "13666",
|
||||
PeerAddr => $HOST,
|
||||
PeerPort => $PORT,
|
||||
)
|
||||
|| die "Cannot connect to LCDproc port\n";
|
||||
|
||||
@@ -55,11 +80,11 @@ while(1)
|
||||
$key = shift @items;
|
||||
if($key eq "E")
|
||||
{
|
||||
system("x11amp --rew");
|
||||
system($XMMS_REWIND);
|
||||
}
|
||||
if($key eq "F")
|
||||
{
|
||||
system("x11amp --fwd");
|
||||
system($XMMS_FORWARD);
|
||||
}
|
||||
}
|
||||
# And ignore everything else
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
# Chicago: KMDW
|
||||
# Graz/Austria (Thalerhof) : LOWG
|
||||
#
|
||||
# More can be found at http://weather.noaa.gov
|
||||
#
|
||||
# no warranty - use at your own risc.
|
||||
# DO NOT PLAN FLIGHTS ETC ON THIS INFORMATION!!!!
|
||||
#
|
||||
@@ -31,11 +33,39 @@
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
############################################################
|
||||
# Configurable part. Set it according your setup.
|
||||
############################################################
|
||||
|
||||
# Host which runs lcdproc daemon (LCDd)
|
||||
$HOST = "localhost";
|
||||
|
||||
# Port on which LCDd listens to requests
|
||||
$PORT = "13666";
|
||||
|
||||
# URL returning weather conditions for specified station code.
|
||||
# Note that $site_code gets replaced by the actual site code,
|
||||
# hence the URL must be in single quotes
|
||||
$URL = 'http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code';
|
||||
|
||||
# Delay (in seconds) between subsequent checks of metar
|
||||
$DELAY = 900;
|
||||
|
||||
# Minimum valid size of metar response
|
||||
$MIN_METAR_SIZE = 10;
|
||||
|
||||
############################################################
|
||||
# End of user configurable parts
|
||||
############################################################
|
||||
|
||||
# Get the site code.
|
||||
|
||||
my $site_code = shift @ARGV;
|
||||
|
||||
die "Usage: $0 <site_code>\n" unless $site_code;
|
||||
die "Usage: $0 <site_code>\n Learn about site codes at http://weather.noaa.gov\n" unless $site_code;
|
||||
|
||||
# replace the string '$site_code' in URL with actual site code
|
||||
$URL =~ s/\$site_code/$site_code/;
|
||||
|
||||
# Get the modules we need.
|
||||
|
||||
@@ -46,8 +76,8 @@ use LWP::UserAgent;
|
||||
# Connect to the server...
|
||||
$remote = IO::Socket::INET->new(
|
||||
Proto => "tcp",
|
||||
PeerAddr => "localhost",
|
||||
PeerPort => "13666",
|
||||
PeerAddr => $HOST,
|
||||
PeerPort => $PORT,
|
||||
)
|
||||
|| die "Cannot connect to LCDproc port\n";
|
||||
|
||||
@@ -77,8 +107,7 @@ print $remote "widget_add metar wind string\n";
|
||||
# set metar source
|
||||
my $ua = new LWP::UserAgent;
|
||||
|
||||
my $req = new HTTP::Request GET =>
|
||||
"http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code";
|
||||
my $req = new HTTP::Request GET => $URL;
|
||||
|
||||
# fetch weather information
|
||||
while (1==1) {
|
||||
@@ -105,7 +134,7 @@ while (1==1) {
|
||||
|
||||
# Sanity check
|
||||
|
||||
if (length($metar)<10) {
|
||||
if (length($metar)<$MIN_METAR_SIZE) {
|
||||
die "METAR is too short! Something went wrong.";
|
||||
}
|
||||
|
||||
@@ -135,8 +164,8 @@ while (1==1) {
|
||||
next if ( $input =~ /^success$/ );
|
||||
#print $input;
|
||||
}
|
||||
print "Sleeping 15 minutes.\n";
|
||||
sleep 900;
|
||||
print "Sleeping " . int ($DELAY / 60) . " minutes.\n";
|
||||
sleep $DELAY;
|
||||
}
|
||||
|
||||
close($remote);
|
||||
|
||||
Reference in New Issue
Block a user