0.4.3 -> 0.5 merging
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
SUBDIRS = examples headlines lcdproc
|
||||
SUBDIRS = examples headlines lcdproc metar
|
||||
|
||||
@@ -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>;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,34 @@
|
||||
use IO::Socket;
|
||||
use Fcntl;
|
||||
|
||||
# iosock.pl - an example client for LCDproc
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
# 2001, David Glaude
|
||||
# 2001, Jarda Benkovsky
|
||||
# 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
|
||||
#
|
||||
|
||||
|
||||
############################################################
|
||||
# Configurable part. Set it according your setup.
|
||||
@@ -50,8 +74,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...
|
||||
@@ -60,13 +87,21 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
||||
|
||||
# Set up some screen widgets...
|
||||
print $remote "client_set name {Test Client (Perl)}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_add pings\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_set pings name {Ping Status}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add pings title title\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set pings title {Ping Status}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add pings one string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add pings two string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set pings one 1 2 {Checking machines...}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
|
||||
my ($machine, %down, %up, $i, $list);
|
||||
@@ -95,6 +130,7 @@ while(1)
|
||||
$list .= "$machine, ";
|
||||
}
|
||||
print $remote "widget_set pings one 1 2 {Machines Up: $i}\n";
|
||||
my $lcdresponse = <$remote>;
|
||||
$i = 0; $list = "";
|
||||
foreach $machine (keys %down)
|
||||
{
|
||||
@@ -102,6 +138,7 @@ while(1)
|
||||
$list .= "$machine, ";
|
||||
}
|
||||
print $remote "widget_set pings two 1 3 {Down ($i): $list}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
}
|
||||
|
||||
close ($remote) || die "close: $!";
|
||||
|
||||
@@ -1,10 +1,33 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# tail.pl - an example client for LCDproc
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
# 2001, David Glaude
|
||||
# 2001, Jarda Benkovsky
|
||||
# 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;
|
||||
@@ -53,8 +76,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...
|
||||
@@ -63,14 +89,31 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
||||
|
||||
# Set up some screen widgets...
|
||||
print $remote "client_set name {Tail}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_add tail\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_set tail name {Tail $filename}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add tail title title\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set tail title {Tail: $filename}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add tail 1 string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add tail 2 string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add tail 3 string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
# NOTE: You have to ask LCDd to send you keys you want to handle
|
||||
print $remote "client_add_key E\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "client_add_key F\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "client_add_key G\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "client_add_key H\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
|
||||
# Forever, we should do stuff...
|
||||
@@ -120,13 +163,17 @@ while(1)
|
||||
else { $line = $lines[$i]; }
|
||||
if(!($line =~ /\S/)) { $line = " ";}
|
||||
print $remote "widget_set tail $j 1 $k {$line }\n";
|
||||
my $lcdresponse = <$remote>;
|
||||
}
|
||||
}
|
||||
else # If the file is unreadable, show an error
|
||||
{
|
||||
print $remote "widget_set tail 1 1 2 {$filename}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set tail 2 1 3 {doesn't exist.}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set tail 3 1 4 { }\n";
|
||||
$lcdresponse = <$remote>;
|
||||
}
|
||||
|
||||
# And wait a little while before we show stuff again.
|
||||
|
||||
@@ -1,16 +1,41 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# x11amp.pl - an example client for LCDproc
|
||||
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# However, it demonstrates one way to handle input from the server.
|
||||
# (although it seems buggy.. oops! :)
|
||||
# Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
# 2001, David Glaude
|
||||
# 2001, Jarda Benkovsky
|
||||
# 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
|
||||
#
|
||||
|
||||
|
||||
# NOTE: 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;
|
||||
@@ -30,7 +55,7 @@ $XMMS = "xmms";
|
||||
|
||||
# Commands to set to previous / next song
|
||||
$XMMS_FORWARD = "$XMMS --fwd";
|
||||
$XMMS_REWIND = "$XMMS --rew"
|
||||
$XMMS_REWIND = "$XMMS --rew";
|
||||
|
||||
############################################################
|
||||
# End of user configurable parts
|
||||
@@ -50,8 +75,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...
|
||||
@@ -60,12 +88,25 @@ fcntl($remote, F_SETFL, O_NONBLOCK);
|
||||
|
||||
# Set up some screen widgets...
|
||||
print $remote "client_set name {X11AMP test}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_add x11amp\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "screen_set x11amp name {X11AMP test}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add x11amp title title\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set x11amp title {X11AMP test}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_add x11amp one string\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "widget_set x11amp one 1 2 { <-: E ; F :->}\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
# NOTE: You have to ask LCDd to send you keys you want to handle
|
||||
print $remote "client_add_key E\n";
|
||||
$lcdresponse = <$remote>;
|
||||
print $remote "client_add_key F\n";
|
||||
$lcdresponse = <$remote>;
|
||||
|
||||
|
||||
while(1)
|
||||
|
||||
+152
-6
@@ -12,9 +12,15 @@
|
||||
#include "mode.h"
|
||||
#include "cpu.h"
|
||||
|
||||
#ifdef SOLARIS
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_CPUVAR_H
|
||||
#include <sys/cpuvar.h>
|
||||
#endif
|
||||
|
||||
@@ -22,6 +28,56 @@
|
||||
#include <kstat.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_KVM_H
|
||||
#include <kvm.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SYSCTL_H
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SCHED_H
|
||||
#include <sys/sched.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_DKSTAT_H
|
||||
#include <sys/dkstat.h>
|
||||
#endif
|
||||
|
||||
#if FREEBSD
|
||||
/* definitions for indices in the nlist array */
|
||||
/* from /usr/src/src.bin/top/machine.c */
|
||||
static struct nlist nlst[] = {
|
||||
#define X_CCPU 0
|
||||
{ "_ccpu" },
|
||||
#define X_CP_TIME 1
|
||||
{ "_cp_time" },
|
||||
{ 0 }
|
||||
};
|
||||
#elif OPENBSD
|
||||
#define X_CP_TIME 0
|
||||
static struct nlist nlst[] = {
|
||||
{ "_cp_time" }, /* 0 */
|
||||
{ 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
struct load {
|
||||
unsigned long total, user, system, nice, idle;
|
||||
};
|
||||
@@ -31,11 +87,22 @@ kstat_ctl_t *kc;
|
||||
#endif
|
||||
|
||||
int load_fd = 0;
|
||||
static void get_load (struct load * result, struct load * last_load );
|
||||
|
||||
static void
|
||||
get_load (struct load *result, struct load * last_load )
|
||||
{
|
||||
#ifdef NETBSD
|
||||
static void netbsd_get_load (struct load * result, struct load * last_load );
|
||||
#define get_load netbsd_get_load
|
||||
#elif defined OPENBSD || FREEBSD
|
||||
static void openfreebsd_get_load (struct load * result, struct load * last_load );
|
||||
#define get_load openfreebsd_get_load
|
||||
#elif defined SOLARIS || LINUX
|
||||
static void linuxsolaris_get_load (struct load * result, struct load * last_load );
|
||||
#define get_load linuxsolaris_get_load
|
||||
#else
|
||||
#error "Does not know how to get the CPU load on your system."
|
||||
#endif
|
||||
|
||||
#if defined LINUX || SOLARIS
|
||||
static void linuxsolaris_get_load (struct load *result, struct load * last_load ) {
|
||||
struct load curr_load;
|
||||
|
||||
#ifndef HAVE_LIBKSTAT
|
||||
@@ -72,13 +139,91 @@ get_load (struct load *result, struct load * last_load )
|
||||
|
||||
*last_load = curr_load ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NETBSD
|
||||
static void netbsd_get_load(struct load * result, struct load * last_load) {
|
||||
struct load curr_load;
|
||||
u_int64_t cp_time[CPUSTATES];
|
||||
size_t size;
|
||||
int mib[2];
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_CP_TIME;
|
||||
size = sizeof(cp_time);
|
||||
|
||||
if(sysctl(mib, 2, cp_time, &size, NULL, 0) < 0) {
|
||||
//fprintf(stderr, "sysctl kern.cp_time failed: %s\n", strerror(errno));
|
||||
curr_load.user = 1;
|
||||
curr_load.nice = 1;
|
||||
curr_load.system = 1;
|
||||
curr_load.idle = 1;
|
||||
} else {
|
||||
curr_load.user = cp_time[CP_USER];
|
||||
curr_load.nice = cp_time[CP_NICE];
|
||||
curr_load.system = cp_time[CP_SYS] + cp_time[CP_INTR];
|
||||
curr_load.idle = cp_time[CP_IDLE];
|
||||
}
|
||||
curr_load.total = curr_load.user + curr_load.nice + curr_load.system + curr_load.idle;
|
||||
result->total = curr_load.total - last_load->total;
|
||||
result->user = curr_load.user - last_load->user;
|
||||
result->nice = curr_load.nice - last_load->nice;
|
||||
result->system = curr_load.system - last_load->system;
|
||||
result->idle = curr_load.idle - last_load->idle;
|
||||
|
||||
*last_load = curr_load ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined OPENBSD || FREEBSD
|
||||
static void openfreebsd_get_load(struct load * result, struct load * last_load) {
|
||||
struct load curr_load;
|
||||
long cp_time[CPUSTATES];
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
kvm_t *kvmd = NULL;
|
||||
|
||||
/* open kernel virtual memory */
|
||||
kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
|
||||
if(kvmd==NULL) {
|
||||
//fprintf(stderr, "kvm_openfiles: %s\n", errbuf);
|
||||
curr_load.user = 1;
|
||||
curr_load.nice = 1;
|
||||
curr_load.system = 1;
|
||||
curr_load.idle = 1;
|
||||
} else {
|
||||
/* ask for specified values */
|
||||
if(kvm_nlist(kvmd, nlst) >= 0) {
|
||||
/* read values for cpu time (user, nice, sys, intr, idle) */
|
||||
if(kvm_read(kvmd, nlst[X_CP_TIME].n_value, (char *)&cp_time, sizeof(cp_time))==sizeof(cp_time)) {
|
||||
curr_load.user = cp_time[CP_USER];
|
||||
curr_load.nice = cp_time[CP_NICE];
|
||||
curr_load.system = cp_time[CP_SYS] + cp_time[CP_INTR];
|
||||
curr_load.idle = cp_time[CP_IDLE];
|
||||
}
|
||||
}
|
||||
kvm_close(kvmd);
|
||||
}
|
||||
curr_load.total = curr_load.user + curr_load.nice + curr_load.system + curr_load.idle;
|
||||
result->total = curr_load.total - last_load->total;
|
||||
result->user = curr_load.user - last_load->user;
|
||||
result->nice = curr_load.nice - last_load->nice;
|
||||
result->system = curr_load.system - last_load->system;
|
||||
result->idle = curr_load.idle - last_load->idle;
|
||||
|
||||
*last_load = curr_load ;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
cpu_init ()
|
||||
{
|
||||
#ifndef HAVE_LIBKSTAT
|
||||
if (!load_fd) {
|
||||
# if defined LINUX || SOLARIS
|
||||
load_fd = open ("/proc/stat", O_RDONLY);
|
||||
# else
|
||||
load_fd=1;
|
||||
# endif
|
||||
}
|
||||
#else
|
||||
kc = kstat_open();
|
||||
@@ -87,7 +232,6 @@ cpu_init ()
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,8 +239,10 @@ int
|
||||
cpu_close ()
|
||||
{
|
||||
#ifndef HAVE_LIBKSTAT
|
||||
# if defined LINUX || SOLARIS
|
||||
if (load_fd)
|
||||
close (load_fd);
|
||||
# endif
|
||||
#else
|
||||
kstat_close(kc);
|
||||
#endif
|
||||
|
||||
+11
-1
@@ -79,6 +79,7 @@ main (int argc, char **argv)
|
||||
int port = LCDPORT;
|
||||
int i, j, k;
|
||||
int tmp;
|
||||
int daemonize=0;
|
||||
|
||||
memset (sequence, 0, sizeof (mode) * MAX_SEQUENCE);
|
||||
|
||||
@@ -112,6 +113,10 @@ main (int argc, char **argv)
|
||||
if (port < 1 && port > 0xffff)
|
||||
fprintf (stderr, "Warning: Port %i outside of standard range\n", port);
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
daemonize=1;
|
||||
break;
|
||||
|
||||
// otherwise... Get help!
|
||||
default:
|
||||
@@ -165,6 +170,11 @@ main (int argc, char **argv)
|
||||
lcd_cellwid = 5;
|
||||
lcd_cellhgt = 8;
|
||||
|
||||
if(daemonize) {
|
||||
if (daemon(1,0)!=0)
|
||||
fprintf(stderr, "Error: daemonize failed");;
|
||||
}
|
||||
|
||||
// Init the status gatherers...
|
||||
mode_init (sequence);
|
||||
|
||||
@@ -180,7 +190,7 @@ void
|
||||
HelpScreen ()
|
||||
{
|
||||
printf ("LCDproc, %s\n", version);
|
||||
printf ("Usage: lcdproc [-s server] [-p port] [modelist]\n");
|
||||
printf ("Usage: lcdproc [-s server] [-p port] [-d] [modelist]\n");
|
||||
printf ("\tOptions in []'s are optional.\n");
|
||||
printf ("\tmodelist is \"mode [mode mode ...]\"\n");
|
||||
printf ("\tMode letters: \t[C]pu [G]raph [T]ime [M]emory [X]load [D]isk [B]attery\n\t\t\tproc_[S]izes [O]ld_time big_cloc[K] [U]ptime CPU_SM[P]\n\t\t\t[A]bout\n");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
bin_SCRIPTS = lcdmetar.pl
|
||||
EXTRA_DIST = lcdmetar.pl
|
||||
Reference in New Issue
Block a user