0.4.3 -> 0.5 merging
This commit is contained in:
@@ -1,5 +1,30 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# fortune.pl - an example client for LCDproc
|
||||
|
||||
# This is just a small example of a client for LCDd the
|
||||
# LCDproc server
|
||||
#
|
||||
# Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
# 2001, David Glaude
|
||||
# 2002, Jonathan Oxer
|
||||
# 2002, Rene Wagner <reenoo@gmx.de>
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This file is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this file; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
#
|
||||
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
@@ -35,8 +60,11 @@ $remote->autoflush(1);
|
||||
sleep 1; # Give server plenty of time to notice us...
|
||||
|
||||
print $remote "hello\n";
|
||||
my $lcdconnect = <$remote>;
|
||||
#print $lcdconnect;
|
||||
# Note: it's good practice to listen for a response after a print to the
|
||||
# server even if there isn't meant to be one. If you don't, you may find
|
||||
# your program crashes after running for a while when the buffers fill up:
|
||||
my $lcdresponse = <$remote>;
|
||||
#print $lcdresponse;
|
||||
|
||||
|
||||
# Turn off blocking mode...
|
||||
@@ -45,11 +73,17 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
||||
|
||||
# Set up some screen widgets...
|
||||
print $remote "client_set name {fortune.pl}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_add fortune\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_set fortune name {Fortune}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add fortune title title\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set fortune title {Fortune}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add fortune text scroller\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
|
||||
&update_text();
|
||||
@@ -86,8 +120,9 @@ sub update_text {
|
||||
$text = `$FORTUNE` || die "\n$0: Error running `$FORTUNE'.\nPlease check that the path is correct.\n\n";
|
||||
@lines = split(/\n/, $text);
|
||||
$text = join(" / ", @lines);
|
||||
|
||||
|
||||
# Now, show a fortune...
|
||||
print $remote "widget_set fortune text 1 2 20 4 v 16 {$text}\n";
|
||||
my $lcdresponse = <$remote>;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user