[Pkg-wmaker-commits] [wmmon] 06/12: Import Debian changes 1.0b2-15

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Aug 12 22:44:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmmon.

commit 5c0f93f75277313531a3f51c19202dc841ea142d
Author: Neil Williams <codehelp at debian.org>
Date:   Sat May 14 18:41:35 2011 +0100

    Import Debian changes 1.0b2-15
    
    wmmon (1.0b2-15) unstable; urgency=low
    
      * QA upload.
      * Apply improvements for SMP machines management (Closes: #552225)
      * Update FSF address in copyright (lintian)
      * Move to 3.0 quilt and turn previous direct changes into a patch.
---
 debian/changelog                            |   9 +
 debian/compat                               |   2 +-
 debian/control                              |   6 +-
 debian/copyright                            |   9 +-
 debian/menu                                 |   2 +-
 debian/patches/existing-changes.diff        | 720 ++++++++++++++++++++++++++++
 debian/patches/series                       |   2 +
 debian/patches/smp-machine-improvement.diff | 304 ++++++++++++
 debian/rules                                |   2 +-
 debian/source/format                        |   1 +
 wmgeneral/wmgeneral.c                       |  24 +-
 wmmon/wmmon.1                               | 192 --------
 wmmon/wmmon.c                               | 253 ++++------
 13 files changed, 1137 insertions(+), 389 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1a3aaa0..05e1e26 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+wmmon (1.0b2-15) unstable; urgency=low
+
+  * QA upload.
+  * Apply improvements for SMP machines management (Closes: #552225)
+  * Update FSF address in copyright (lintian)
+  * Move to 3.0 quilt and turn previous direct changes into a patch.
+
+ -- Neil Williams <codehelp at debian.org>  Sat, 14 May 2011 18:41:35 +0100
+
 wmmon (1.0b2-14) unstable; urgency=medium
 
   * Fixed build dependencies so we no longer depend on libxpm4-dev.
diff --git a/debian/compat b/debian/compat
index b8626c4..7f8f011 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-4
+7
diff --git a/debian/control b/debian/control
index 5c23675..a2f3299 100644
--- a/debian/control
+++ b/debian/control
@@ -1,9 +1,9 @@
 Source: wmmon
 Section: x11
 Priority: optional
-Maintainer: Simon Law <sfllaw at debian.org>
-Standards-Version: 3.6.1
-Build-Depends: debhelper (>> 4.0.0), libx11-dev, libxpm-dev, libxext-dev
+Maintainer: Debian QA Group <packages at qa.debian.org>
+Standards-Version: 3.9.2
+Build-Depends: debhelper (>> 7), libx11-dev, libxpm-dev, libxext-dev
 
 Package: wmmon
 Architecture: any
diff --git a/debian/copyright b/debian/copyright
index 9bd1814..57dc063 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -18,8 +18,11 @@ Upstream Copyright:
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    along with this program; if not, contact:
+
+    Free Software Foundation           Voice:  +1-617-542-5942
+    51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+    Boston, MA  02110-1301,  USA       gnu at gnu.org
 
 On Debian GNU/Linux systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
diff --git a/debian/menu b/debian/menu
index 829500d..a8ae208 100644
--- a/debian/menu
+++ b/debian/menu
@@ -1,6 +1,6 @@
 ?package(wmmon):\
 	needs="X11"\
-	section="Apps/System"\
+	section="Applications/System/Monitoring"\
 	title="WMmon"\
 	command="/usr/bin/wmmon"\
 	hints="Monitoring,Dockapp"
diff --git a/debian/patches/existing-changes.diff b/debian/patches/existing-changes.diff
new file mode 100644
index 0000000..fe733ea
--- /dev/null
+++ b/debian/patches/existing-changes.diff
@@ -0,0 +1,720 @@
+Description: Include changes from existing package 1.0b2-14.
+ Changes include providing a manpage and the following:
+ 15/05/2004 (Simon Law, sfllaw at debian.org)
+ * Support disabling of mode-cycling
+ 23/10/2003 (Simon Law, sfllaw at debian.org)
+ * Eliminated exploitable static buffers
+ * Added -geometry support.
+ * /proc/meminfo support for Linux 2.6
+ 10/10/2003 (Simon Law, sfllaw at debian.org)
+
+---
+
+--- wmmon-1.0b2.orig/wmmon/wmmon.c
++++ wmmon-1.0b2/wmmon/wmmon.c
+@@ -28,6 +28,12 @@
+ 	Changes:
+ 	----
+ 
++	15/05/2004 (Simon Law, sfllaw at debian.org)
++		* Support disabling of mode-cycling
++	23/10/2003 (Simon Law, sfllaw at debian.org)
++		* Eliminated exploitable static buffers
++		* Added -geometry support.
++		* /proc/meminfo support for Linux 2.6
+ 	18/05/1998 (Antoine Nulle, warp at xs4all.nl)
+ 		* MEM/SWAP/UPTIME only updated when visible
+ 		* Using global file descriptors to reduce file
+@@ -65,6 +71,7 @@
+ 		* First Working Version
+ */
+ 
++#define _GNU_SOURCE
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <time.h>
+@@ -100,31 +107,28 @@
+  /* Global Variables */
+ /********************/
+ 
+-char	*ProgName;
+ int	stat_current = 0; /* now global */
++int mode_cycling = 1; /* Allow mode-cycling */
+ FILE	*fp_meminfo;
+ FILE	*fp_stat;
+ FILE	*fp_loadavg;
+ 
+ /* functions */
+-void usage(void);
++void usage(char*);
+ void printversion(void);
+ void DrawStats(int *, int, int, int, int);
+ void DrawStats_io(int *, int, int, int, int);
+ 
+ void wmmon_routine(int, char **);
+ 
+-void main(int argc, char *argv[]) {
++int main(int argc, char *argv[]) {
+ 
+ 	int		i;
++	char	*name = argv[0];
+ 	
+ 
+ 	/* Parse Command Line */
+ 
+-	ProgName = argv[0];
+-	if (strlen(ProgName) >= 5)
+-		ProgName += (strlen(ProgName) - 5);
+-	
+ 	for (i=1; i<argc; i++) {
+ 		char *arg = argv[i];
+ 
+@@ -132,13 +136,17 @@ void main(int argc, char *argv[]) {
+ 			switch (arg[1]) {
+ 			case 'd' :
+ 				if (strcmp(arg+1, "display")) {
+-					usage();
+-					exit(1);
++					usage(name);
++					return 1;
+ 				}
+ 				break;
+-			case 'v' :
+-				printversion();
+-				exit(0);
++			case 'g' :
++				if (strcmp(arg+1, "geometry")) {
++					usage(name);
++					return 1;
++				}
++			case 'l' :
++				mode_cycling = 0;
+ 				break;
+ 			case 'i' :
+ 				stat_current = 1;
+@@ -146,15 +154,20 @@ void main(int argc, char *argv[]) {
+ 			case 's' :
+ 				stat_current = 2;
+ 				break;
++			case 'v' :
++				printversion();
++				return 0;
+ 			default:
+-				usage();
+-				exit(0);
+-				break;
++				usage(name);
++				return 1;
+ 			}
+ 		}
+ 	}
+ 
+ 	wmmon_routine(argc, argv);
++  
++      exit (0);
++   
+ }
+ 
+ /*******************************************************************************\
+@@ -214,8 +227,7 @@ void wmmon_routine(int argc, char **argv
+ 	long		idle;
+ 
+ 	FILE		*fp;
+-	char		temp[128];
+-	char		*p;
++	char		*conffile = NULL;
+ 
+ 	int			xpm_X = 0, xpm_Y = 0;
+ 
+@@ -246,16 +258,21 @@ void wmmon_routine(int argc, char **argv
+ 	if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION);
+ 	if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION);
+ 
+-	strcpy(temp, "/etc/wmmonrc");
+-	parse_rcfile(temp, wmmon_keys);
++	/* Scan through the .rc files */
++	if (asprintf(&conffile, "/etc/wmmonrc") >= 0) {
++		parse_rcfile(conffile, wmmon_keys);
++		free(conffile);
++	}
+ 
+-	p = getenv("HOME");
+-	strcpy(temp, p);
+-	strcat(temp, "/.wmmonrc");
+-	parse_rcfile(temp, wmmon_keys);
+-	
+-	strcpy(temp, "/etc/wmmonrc.fixed");
+-	parse_rcfile(temp, wmmon_keys);
++	if (asprintf(&conffile, "%s/.wmmonrc", getenv("HOME")) >= 0) {
++		parse_rcfile(conffile, wmmon_keys);
++		free(conffile);
++	}
++
++	if (asprintf(&conffile, "/etc/wmmonrc.fixed") >= 0) {
++		parse_rcfile(conffile, wmmon_keys);
++		free(conffile);
++	}
+ 
+ 	stat_online = checksysdevs();
+ 
+@@ -269,26 +286,36 @@ void wmmon_routine(int argc, char **argv
+ 	starttime = time(0);
+ 	nexttime = starttime + 10;
+ 
++	/* Collect information on each panel */
+ 	for (i=0; i<stat_online; i++) {
+ 		get_statistics(stat_device[i].name, &k, &istat, &idle);
+ 		stat_device[i].statlast = istat;
+ 		stat_device[i].idlelast = idle;
+ 	}
+-	if (stat_current == 0) DrawStats(stat_device[stat_current].his, 54, 40, 5, 58);
+-	if (stat_current == 1) {
+-		DrawStats_io(stat_device[stat_current].his, 54, 40, 5, 58);
+-	}
+-	if (stat_current == 2) {
+-		xpm_X = 64;
+-		setMaskXY(-64, 0);
+-	} else {
+-		xpm_X = 0;
+-		setMaskXY(0, 0);
++
++	/* Set the mask for the current window */
++	switch (stat_current) {
++		case 0:
++		case 1:
++			xpm_X = 0;
++			setMaskXY(0, 0);
++			break;
++		case 2:
++			xpm_X = 64;
++			setMaskXY(-64, 0);
++		default:
++			break;
+ 	}
++
++	/* Draw statistics */
++	if (stat_current == 0)
++		DrawStats(stat_device[stat_current].his, 54, 40, 5, 58);
++	if (stat_current == 1)
++		DrawStats_io(stat_device[stat_current].his, 54, 40, 5, 58);
+ 	DrawActive(stat_device[stat_current].name);
+ 
+ 	while (1) {
+-		curtime = time(0);
++		curtime = time(NULL);
+ 
+ 		waitpid(0, NULL, WNOHANG);
+ 
+@@ -377,6 +404,9 @@ void wmmon_routine(int argc, char **argv
+ 		if (curtime >= nexttime) {
+ 			nexttime+=10;
+ 
++			if (curtime > nexttime) /* dont let APM suspends make this crazy */
++			  nexttime = curtime;
++
+ 			for (i=0; i<stat_online; i++) {
+ 				if (stat_device[i].his[54])
+ 					stat_device[i].his[54] /= stat_device[i].hisaddcnt;
+@@ -411,7 +441,7 @@ void wmmon_routine(int argc, char **argv
+ 				break;
+ 			case ButtonRelease:
+ 				i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
+-				if (but_stat == i && but_stat >= 0) {
++				if (but_stat == i && but_stat >= 0 && mode_cycling) {
+ 					switch (but_stat) {
+ 					case 0:
+ 						switch (Event.xbutton.button) {
+@@ -430,7 +460,6 @@ void wmmon_routine(int argc, char **argv
+ 						}
+ 					case 1:
+ 						stat_current++;
+-						printf("current stat is :%d\n", stat_current);
+ 						if (stat_current == stat_online)
+ 							stat_current = 0;
+ 
+@@ -499,43 +528,80 @@ void update_stat_io(stat_dev *st) {
+ 
+ void update_stat_mem(stat_dev *st, stat_dev *st2) {
+ 
+-	char	temp[128];
++	static char *line = NULL;
++	static size_t line_size = 0;
++
++	unsigned long swapfree;
+ 	unsigned long free, shared, buffers, cached;
+ 
+ 	freopen("/proc/meminfo", "r", fp_meminfo);
+-	while (fgets(temp, 128, fp_meminfo)) {
+-		if (strstr(temp, "Mem:")) {
+-			sscanf(temp, "Mem: %ld %ld %ld %ld %ld %ld",
+-			       &st->rt_idle, &st->rt_stat,
+-			       &free, &shared, &buffers, &cached);
+-			st->rt_idle >>= 10;
+-			st->rt_stat -= buffers+cached;
+-			st->rt_stat >>= 10;
+-//			break;
+-		}
+-		if (strstr(temp, "Swap:")) {
+-			sscanf(temp, "Swap: %ld %ld", &st2->rt_idle, &st2->rt_stat);
+-			st2->rt_idle >>= 10;
+-			st2->rt_stat >>= 10;
+-			break;
++	while ((getline(&line, &line_size, fp_meminfo)) > 0) {
++		/* The original format for the first two lines of /proc/meminfo was
++		 * Mem: total used free shared buffers cached
++		 * Swap: total used free
++		 *
++		 * As of at least 2.5.47 these two lines were removed, so that the
++		 * required information has to come from the rest of the lines.
++		 * On top of that, used is no longer recorded - you have to work
++		 * this out yourself, from total - free.
++		 *
++		 * So, these changes below should work. They should also work with
++		 * older kernels, too, since the new format has been available for
++		 * ages.
++		 */
++		if (strstr(line, "MemTotal:")) {
++			sscanf(line, "MemTotal: %ld", &st->rt_idle);
++		}
++		else if (strstr(line, "MemFree:")) {
++			sscanf(line, "MemFree: %ld", &free);
++		}
++		else if (strstr(line, "MemShared:")) {
++			sscanf(line, "MemShared: %ld", &shared);
++		}
++		else if (strstr(line, "Buffers:")) {
++			sscanf(line, "Buffers: %ld", &buffers);
++		}
++		else if (strstr(line, "Cached:")) {
++			sscanf(line, "Cached: %ld", &cached);
++		}
++		else if (strstr(line, "SwapTotal:")) {
++			sscanf(line, "SwapTotal: %ld", &st2->rt_idle);
++		}
++		else if (strstr(line, "SwapFree:")) {
++			sscanf(line, "SwapFree: %ld", &swapfree);
+ 		}
+ 	}
++
++	/* memory use - rt_stat is the amount used, it seems, and this isn't
++	 * recorded in current version of /proc/meminfo (as of 2.5.47), so we
++	 * calculate it from MemTotal - MemFree
++	 */
++	st->rt_stat = st->rt_idle - free;
++	st->rt_stat -= buffers+cached;
++	/* As with the amount of memory used, it's not recorded any more, so
++	 * we have to calculate it ourselves.
++	 */
++	st2->rt_stat = st2->rt_idle - swapfree;
+ }
+ 
+ void update_stat_swp(stat_dev *st) {
+ 
+-	char	temp[128];
++	static char *line = NULL;
++	static size_t line_size = 0;
++	unsigned long swapfree;
+ 
+ 	fseek(fp_meminfo, 0, SEEK_SET);
+-	while (fgets(temp, 128, fp_meminfo)) {
+-		if (strstr(temp, "Swap:")) {
+-			sscanf(temp, "Swap: %ld %ld", &st->rt_idle, &st->rt_stat);
+-			st->rt_idle >>= 10;
+-			st->rt_stat >>= 10;
+-			break;
++	while ((getline(&line, &line_size, fp_meminfo)) > 0) {
++		/* As with update_stat_mem(), the format change to /proc/meminfo has
++		 * forced some changes here. */
++		if (strstr(line, "SwapTotal:")) {
++			sscanf(line, "SwapTotal: %ld", &st->rt_idle);
++		}
++		else if (strstr(line, "SwapFree:")) {
++			sscanf(line, "SwapFree: %ld", &swapfree);
+ 		}
+ 	}
+-
++	st->rt_stat = st->rt_idle - swapfree;
+ }
+ 
+ /*******************************************************************************\
+@@ -545,11 +611,11 @@ void update_stat_swp(stat_dev *st) {
+ void get_statistics(char *devname, long *is, long *ds, long *idle) {
+ 
+ 	int	i;
+-	char	temp[128];
++	static char *line = NULL;
++	static size_t line_size = 0;
+ 	char	*p;
+ 	char	*tokens = " \t\n";
+ 	float	f;
+-	long	maxdiskio=0;
+ 
+ 	*is = 0;
+ 	*ds = 0;
+@@ -557,9 +623,9 @@ void get_statistics(char *devname, long
+ 
+ 	if (!strncmp(devname, "cpu", 3)) {
+ 		fseek(fp_stat, 0, SEEK_SET);
+-		while (fgets(temp, 128, fp_stat)) {
+-			if (strstr(temp, "cpu")) {
+-				p = strtok(temp, tokens);
++		while ((getline(&line, &line_size, fp_stat)) > 0) {
++			if (strstr(line, "cpu ")) {
++				p = strtok(line, tokens);
+ 				/* 1..3, 4 == idle, we don't want idle! */
+ 				for (i=0; i<3; i++) {
+ 					p = strtok(NULL, tokens);
+@@ -577,17 +643,35 @@ void get_statistics(char *devname, long
+ 	if (!strncmp(devname, "i/o", 3)) {
+ 
+ 		fseek(fp_stat, 0, SEEK_SET);
+-		while (fgets(temp, 128, fp_stat)) {
+-			if (strstr(temp, "disk_rio") || strstr(temp, "disk_wio")) {
+-				p = strtok(temp, tokens);
++		while ((getline(&line, &line_size, fp_stat)) > 0) {
++			if (strstr(line, "disk_rio") || strstr(line, "disk_wio")) {
++				p = strtok(line, tokens);
+ 				/* 1..4 */
+ 				for (i=0; i<4; i++) {
+ 					p = strtok(NULL, tokens);
+ 					*ds += atol(p);
+ 				}
+ 			}
++			else if (strstr(line, "disk_io")) {
++				int val;
++				unsigned int a, b, c, d, e, h, g;
++   
++				p = strtok(line, tokens);
++   
++				while ((p = strtok(NULL, tokens))) {
++					val = sscanf (p,
++						      "(%d,%d):(%d,%d,%d,%d,%d)",
++						      &a, &b, &c, &d, &e, &h,
++						      &g);
++   
++					if (val != 7)
++						continue;
++   
++					*ds += d;
++					*ds += h;
++				}
++			}
+ 		}
+-		if (*ds > maxdiskio) maxdiskio = *ds;
+ 	}
+ }
+ 
+@@ -715,16 +799,17 @@ void DrawStats_io(int *his, int num, int
+ |* usage																	   *|
+ \*******************************************************************************/
+ 
+-void usage(void) {
+-
+-	fprintf(stderr, "\nwmmon - programming: tijno, (de)bugging & design warp, webhosting: bobby\n\n");
+-	fprintf(stderr, "usage:\n");
+-	fprintf(stderr, "\t-display <display name>\n");
+-	fprintf(stderr, "\t-h\tthis screen\n");
+-	fprintf(stderr, "\t-v\tprint the version number\n");
+-	fprintf(stderr, "\t-i\tstartup in DiskIO mode\n");
+-	fprintf(stderr, "\t-s\tstartup in SysInfo mode\n");
+-	fprintf(stderr, "\n");
++void usage(char *name) {
++	printf("Usage: %s [OPTION]...\n", name);
++	printf("WindowMaker dockapp that displays system information.\n");
++	printf("\n");
++	printf("  -display DISPLAY     contact the DISPLAY X server\n");
++	printf("  -geometry GEOMETRY   position the clock at GEOMETRY\n");
++	printf("  -l                   locked view - cannot cycle modes\n");
++	printf("  -i                   start in Disk I/O mode\n");
++	printf("  -s                   start in System Info mode\n");
++	printf("  -h                   display this help and exit\n");
++	printf("  -v                   output version information and exit\n");
+ }
+ 
+ /*******************************************************************************\
+@@ -733,7 +818,7 @@ void usage(void) {
+ 
+ void printversion(void) {
+ 
+-	if (!strcmp(ProgName, "wmmon")) {
+-		fprintf(stderr, "%s\n", WMMON_VERSION);
+-	}
++	printf("WMMon version %s\n", WMMON_VERSION);
+ }
++/* vim: sw=4 ts=4 columns=82
++ */
+--- /dev/null
++++ wmmon-1.0b2/wmmon/wmmon.1
+@@ -0,0 +1,192 @@
++'\" t
++.\" Man page for wmmon
++.\" Copyright (c) 2003  Software in the Public Interest, Inc.
++.\"
++.\" This program 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 (at
++.\" your option) any later version.
++.\"
++.\" This program 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 program; if not, write to the Free Software
++.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
++.\"
++.TH wmmon 1 "May 1998" "WMMON 1.0b2"
++
++.SH NAME
++wmmon \- Window Maker dockapp for monitoring system information
++
++.SH SYNOPSIS
++
++.B wmmon
++[
++.I OPTION
++]
++
++.SH DESCRIPTION
++
++.B WMMon
++monitors the realtime CPU load as well as the average system load,
++and gives you some nice additional features too. It is intended for
++docking in Window Maker.
++
++It currently provides:
++
++.IP \(bu 4
++a realtime CPU stress meter;
++.IP \(bu
++an auto-scaled average system load meter, like
++.B xload
++and
++.BR wmavgload ;
++.IP \(bu
++a realtime disk I/O stress meter;
++.IP \(bu
++auto-scaled disk I/O load meter;
++.IP \(bu
++realtime memory and swap usage meters;
++.IP \(bu
++a display for system uptime;
++.IP \(bu
++three user-defined commands to launch.
++
++.SH OPTIONS
++
++.TP
++.BI \-display \ display
++This option specifies the X server to contact; see
++.IR X(7x) .
++
++.TP
++.BI \-geometry \ geometry
++This option specifies the preferred position of clock; see
++.IR X(7x) .
++
++.TP
++.BR \-l
++Lock the mode, so that it cannot be cycled by clicking on the upper-left
++widget.  You can use this to open multiple copies of
++.BR WMMon ,
++each set to a different mode.
++
++.TP
++.BR \-i
++Start in disk I/O mode, which displays instantaneous disk usage and
++average disk load.
++
++.TP
++.BR \-s
++Start in system information mode, which displays memory usage, swap usage,
++and uptime.
++
++.TP
++.B \-h
++Show help information.
++
++.TP
++.B \-v
++Print the version number.
++
++.SH USAGE
++The
++.B WMMon
++display can be cycled between CPU, disk I/O, and system
++information displays by clicking on the upper-left widget.  This
++displays CPU information by default.
++
++WMMon can also be used to launch programs.  You may click either left,
++middle, or right mouse buttons in the average-load section of the
++window.  The pre-configured program will be launched according to the
++mouse button clicked.  (see
++.B CONFIGURATION FILE
++below.)
++
++In order to move
++.BR WMMon ,
++drag on the outer edges.  These are not sensitive to mouse clicks.
++
++.SH "DOCKING IN WINDOW MANAGERS"
++
++.TP
++Window Maker
++
++Window Maker users should drag and drop the
++.B WMMon
++window on the Dock.  Then, right-click on the border of the window and
++select \*(lqSettings...\*(rq.  Check \*(lqStart when Window Maker
++is started\*(rq.
++
++.TP
++AfterStep
++
++AfterStep users should put the following in their
++.I $HOME/.steprc
++
++.RS 16
++Wharf wmmon \- MaxSwallow "wmmon" wmmon &
++.RE
++
++.TP
++Other window managers
++
++.B WMMon
++runs nicely as a 64x64 shaped icon on your desktop.
++
++.SH "CONFIGURATION FILE"
++
++.B WMMon
++can launch three user-defined commands, triggered by left, middle and
++right mouse button clicks.  You can define the commands to launch in
++.I $HOME/.wmmonrc
++
++.RS
++.PD 0
++left: xterm
++.PP
++middle: xload
++.PP
++right: xcalc
++.PP
++.PD 
++.RE
++
++If
++.B WMMon
++detects a
++.I $HOME/.wmmonrc
++file, it will launch the appropriate command when you click on the clock.
++
++The system administrator can define default commands in
++.IR /etc/wmmonrc .
++The administrator may also choose to \*(lqfix\*(rq particular commands,
++making it impossible for users to change.  These commands can be defined in
++.IR /etc/wmmonrc.fixed ,
++although this isn't a nice thing to do.
++
++.SH FILES
++
++.I /etc/wmmonrc
++.br
++.I $HOME/.wmmonrc
++.br
++.I /etc/wmmonrc.fixed
++
++.SH AUTHORS
++
++.B WMMon
++was written by Martijn Pieterse and Antoine Nulle.
++
++This manual page was written by Simon Law <sfllaw at debian.org> for the
++.B Debian
++system (but may be used by others). It is based on the documentation provided
++by the original program.
++
++This manual 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 (at
++your option) any later version.
+--- wmmon-1.0b2.orig/wmgeneral/wmgeneral.c
++++ wmmon-1.0b2/wmgeneral/wmgeneral.c
+@@ -12,6 +12,8 @@
+ 	---
+ 	CHANGES:
+ 	---
++	10/10/2003 (Simon Law, sfllaw at debian.org)
++		* changed the parse_rcfile function to use getline instead of fgets.
+ 	02/05/1998 (Martijn Pieterse, pieterse at xs4all.nl)
+ 		* changed the read_rc_file to parse_rcfile, as suggester by Marcelo E. Magallon
+ 		* debugged the parse_rc file.
+@@ -21,6 +23,7 @@
+ 
+ */
+ 
++#define _GNU_SOURCE
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+@@ -83,17 +86,18 @@ int CheckMouseRegion(int, int);
+ void parse_rcfile(const char *filename, rckeys *keys) {
+ 
+ 	char	*p;
+-	char	temp[128];
++	char	*line = NULL;
++	size_t  line_size = 0;
+ 	char	*tokens = " :\t\n";
+ 	FILE	*fp;
+ 	int		i,key;
+ 
+ 	fp = fopen(filename, "r");
+ 	if (fp) {
+-		while (fgets(temp, 128, fp)) {
++		while (getline(&line, &line_size, fp) >= 0) {
+ 			key = 0;
+ 			while (key >= 0 && keys[key].label) {
+-				if ((p = strstr(temp, keys[key].label))) {
++				if ((p = strstr(line, keys[key].label))) {
+ 					p += strlen(keys[key].label);
+ 					p += strspn(p, tokens);
+ 					if ((i = strcspn(p, "#\n"))) p[i] = 0;
+@@ -270,6 +274,7 @@ void openXwindow(int argc, char *argv[],
+ 	unsigned int	borderwidth = 1;
+ 	XClassHint		classHint;
+ 	char			*display_name = NULL;
++	char			*geometry = NULL;
+ 	char			*wname = argv[0];
+ 	XTextProperty	name;
+ 
+@@ -282,7 +287,9 @@ void openXwindow(int argc, char *argv[],
+ 
+ 	for (i=1; argv[i]; i++) {
+ 		if (!strcmp(argv[i], "-display")) 
+-			display_name = argv[i+1];
++			display_name = argv[++i];
++		else if (!strcmp(argv[i], "-geometry"))
++			geometry = argv[++i];
+ 	}
+ 
+ 	if (!(display = XOpenDisplay(display_name))) {
+@@ -307,7 +314,11 @@ void openXwindow(int argc, char *argv[],
+ 	fore_pix = GetColor("black");
+ 
+ 	XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
+-				&mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
++	            &mysizehints.x, &mysizehints.y,
++	            &mysizehints.width, &mysizehints.height, &dummy);
++	if (geometry)
++		XParseGeometry(geometry, &mysizehints.x, &mysizehints.y,
++		               &mysizehints.width, &mysizehints.height);
+ 
+ 	mysizehints.width = 64;
+ 	mysizehints.height = 64;
+@@ -364,3 +375,6 @@ void openXwindow(int argc, char *argv[],
+ 	XMapWindow(display, win);
+ 
+ }
++
++/* vim: sw=4 ts=4 columns=82
++ */
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..5673b9b
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+existing-changes.diff
+smp-machine-improvement.diff
diff --git a/debian/patches/smp-machine-improvement.diff b/debian/patches/smp-machine-improvement.diff
new file mode 100644
index 0000000..188ea7e
--- /dev/null
+++ b/debian/patches/smp-machine-improvement.diff
@@ -0,0 +1,304 @@
+Description: Apply improvements for SMP machines management (Closes: #552225)
+Author: Romuald DELAVERGNE <romuald.delavergne at free.fr>
+Bug-Debian: http://bugs.debian.org/552225
+
+--- wmmon-1.0b2.orig/wmmon/wmmon.c
++++ wmmon-1.0b2/wmmon/wmmon.c
+@@ -28,6 +28,8 @@
+ 	Changes:
+ 	----
+ 
++	17/10/2009 (Romuald Delavergne, romuald.delavergne at free.fr)
++		* Support SMP processors in realtime CPU stress meter
+ 	15/05/2004 (Simon Law, sfllaw at debian.org)
+ 		* Support disabling of mode-cycling
+ 	23/10/2003 (Simon Law, sfllaw at debian.org)
+@@ -109,6 +111,7 @@
+ 
+ int	stat_current = 0; /* now global */
+ int mode_cycling = 1; /* Allow mode-cycling */
++int cpu_avg_max  = 0; /* CPU stress meter with average and max for SMP */
+ FILE	*fp_meminfo;
+ FILE	*fp_stat;
+ FILE	*fp_loadavg;
+@@ -148,6 +151,9 @@ int main(int argc, char *argv[]) {
+ 			case 'l' :
+ 				mode_cycling = 0;
+ 				break;
++			case 'c' :
++				cpu_avg_max = 1;
++				break;
+ 			case 'i' :
+ 				stat_current = 1;
+ 				break;
+@@ -174,6 +180,7 @@ int main(int argc, char *argv[]) {
+ |* wmmon_routine															   *|
+ \*******************************************************************************/
+ 
++#define MAX_CPU (10) /* depends on graph height */
+ typedef struct {
+ 
+ 	char	name[5];			/* "cpu0..cpuz", eventually.. :) */
+@@ -183,6 +190,11 @@ typedef struct {
+ 	long	statlast;
+ 	long	rt_idle;
+ 	long	idlelast;
++	/* Processors stats */
++	long	*cpu_stat;
++	long	*cpu_last;
++	long	*idle_stat;
++	long	*idle_last;
+ 	
+ } stat_dev;
+ 
+@@ -194,11 +206,14 @@ char		*right_action;
+ char		*middle_action;
+ 
+ 
++int	nb_cpu, cpu_max;
++int getNbCPU(void);
++unsigned long getWidth(long, long);
+ int checksysdevs(void);
+-void get_statistics(char *, long *, long *, long *);
++void get_statistics(char *, long *, long *, long *, long *, long *);
+ void DrawActive(char *);
+ 
+-void update_stat_cpu(stat_dev *);
++void update_stat_cpu(stat_dev *, long *, long *);
+ void update_stat_io(stat_dev *);
+ void update_stat_mem(stat_dev *st, stat_dev *st2);
+ void update_stat_swp(stat_dev *);
+@@ -225,6 +240,8 @@ void wmmon_routine(int argc, char **argv
+ 
+ 	long		istat;
+ 	long		idle;
++	long		*istat2;
++	long		*idle2;
+ 
+ 	FILE		*fp;
+ 	char		*conffile = NULL;
+@@ -276,6 +293,21 @@ void wmmon_routine(int argc, char **argv
+ 
+ 	stat_online = checksysdevs();
+ 
++	nb_cpu = getNbCPU();
++	stat_device[0].cpu_stat = calloc(nb_cpu, sizeof(long));
++	stat_device[0].cpu_last = calloc(nb_cpu, sizeof(long));
++	stat_device[0].idle_stat = calloc(nb_cpu, sizeof(long));
++	stat_device[0].idle_last = calloc(nb_cpu, sizeof(long));
++	if (!stat_device[0].cpu_stat || !stat_device[0].cpu_last || !stat_device[0].idle_stat || !stat_device[0].idle_last) {
++		fprintf(stderr, "%s: Unable to alloc memory !\n", argv[0]);
++		exit(1);
++	}
++	istat2 = calloc(nb_cpu, sizeof(long));
++	idle2 = calloc(nb_cpu, sizeof(long));
++	if (!istat2 || !idle2) {
++		fprintf(stderr, "%s: Unable to alloc memory !!\n", argv[0]);
++		exit(1);
++	}
+ 
+ 	openXwindow(argc, argv, wmmon_master_xpm, wmmon_mask_bits, wmmon_mask_width, wmmon_mask_height);
+ 
+@@ -288,9 +320,16 @@ void wmmon_routine(int argc, char **argv
+ 
+ 	/* Collect information on each panel */
+ 	for (i=0; i<stat_online; i++) {
+-		get_statistics(stat_device[i].name, &k, &istat, &idle);
++		get_statistics(stat_device[i].name, &k, &istat, &idle, istat2, idle2);
+ 		stat_device[i].statlast = istat;
+ 		stat_device[i].idlelast = idle;
++		if (i == 0 && nb_cpu > 1) {
++			int cpu;
++			for (cpu = 0; cpu < nb_cpu; cpu++) {
++				stat_device[i].cpu_last[cpu] = istat2[cpu];
++				stat_device[i].idle_last[cpu] = idle2[cpu];
++			}
++		}
+ 	}
+ 
+ 	/* Set the mask for the current window */
+@@ -320,7 +359,7 @@ void wmmon_routine(int argc, char **argv
+ 		waitpid(0, NULL, WNOHANG);
+ 
+ 
+-		update_stat_cpu(&stat_device[0]);
++		update_stat_cpu(&stat_device[0], istat2, idle2);
+ 		update_stat_io(&stat_device[1]);
+ 
+ 		if(stat_current == 2) {
+@@ -334,13 +373,26 @@ void wmmon_routine(int argc, char **argv
+ 			/* Load ding is 45 pixels hoog */
+ 			copyXPMArea(0, 64, 32, 12, 28, 4);
+ 
+-			j = (stat_device[i].rt_stat + stat_device[i].rt_idle);
+-			if (j != 0) {
+-				j = (stat_device[i].rt_stat * 100) / j;
++			if (i == 0 && nb_cpu > 1) {
++				if (nb_cpu > MAX_CPU || cpu_avg_max) {
++					/* show average CPU */
++					j = getWidth(stat_device[i].rt_stat, stat_device[i].rt_idle);
++					copyXPMArea(32, 64, j, 6, 28, 4);
++					/* Show max CPU */
++					j = getWidth(stat_device[i].cpu_stat[cpu_max], stat_device[i].idle_stat[cpu_max]);
++					copyXPMArea(32, 70, j, 6, 28, 10);
++				} else {
++					int cpu;
++					for (cpu = 0; cpu < nb_cpu; cpu++) {
++						j = getWidth(stat_device[i].cpu_stat[cpu], stat_device[i].idle_stat[cpu]);
++						copyXPMArea(32, 65, j, MAX_CPU/nb_cpu, 28, 5+(MAX_CPU/nb_cpu)*cpu);
++					}
++				}
++			}
++			else {
++				j = getWidth(stat_device[i].rt_stat, stat_device[i].rt_idle);
++				copyXPMArea(32, 64, j, 12, 28, 4);
+ 			}
+-			j = j * 0.32;
+-			if (j > 32) j = 32;
+-			copyXPMArea(32, 64, j, 12, 28, 4);
+ 		} else {
+ 			/* Nu zal ie wel 3 zijn. */
+ 
+@@ -487,11 +539,10 @@ void wmmon_routine(int argc, char **argv
+ 	}
+ }
+ 
+-void update_stat_cpu(stat_dev *st) {
+-
++void update_stat_cpu(stat_dev *st, long *istat2, long *idle2) {
+ 	long	k, istat, idle;
+ 
+-	get_statistics(st->name, &k, &istat, &idle);
++	get_statistics(st->name, &k, &istat, &idle, istat2, idle2);
+ 
+ 	st->rt_idle = idle - st->idlelast;
+ 	st->idlelast = idle;
+@@ -499,6 +550,26 @@ void update_stat_cpu(stat_dev *st) {
+ 	st->rt_stat = istat - st->statlast;
+ 	st->statlast = istat;
+ 
++	if (nb_cpu > 1) {
++		int cpu;
++		unsigned long  max, j;
++		cpu_max = 0; max = 0;
++		for (cpu = 0; cpu < nb_cpu; cpu++) {
++			st->idle_stat[cpu] = idle2[cpu] - st->idle_last[cpu];
++			st->idle_last[cpu] = idle2[cpu];
++
++			st->cpu_stat[cpu] = istat2[cpu] - st->cpu_last[cpu];
++			st->cpu_last[cpu] = istat2[cpu];
++
++			j = st->cpu_stat[cpu] + st->idle_stat[cpu];
++			if (j != 0)  j = (st->cpu_stat[cpu] << 7) / j;
++			if (j > max) {
++				max = j;
++				cpu_max = cpu;
++			}
++		}
++	}
++
+ 	st->his[54] += k;
+ 	st->hisaddcnt += 1;
+ }
+@@ -508,7 +579,7 @@ void update_stat_io(stat_dev *st) {
+ 	long			j, k, istat, idle;
+ 	static long		maxdiskio = 0;
+ 
+-	get_statistics(st->name, &k, &istat, &idle);
++	get_statistics(st->name, &k, &istat, &idle, NULL, NULL);
+ 
+ 	st->rt_idle = idle - st->idlelast;
+ 	st->idlelast = idle;
+@@ -608,7 +679,7 @@ void update_stat_swp(stat_dev *st) {
+ |* get_statistics															   *|
+ \*******************************************************************************/
+ 
+-void get_statistics(char *devname, long *is, long *ds, long *idle) {
++void get_statistics(char *devname, long *is, long *ds, long *idle, long *ds2, long *idle2) {
+ 
+ 	int	i;
+ 	static char *line = NULL;
+@@ -624,15 +695,27 @@ void get_statistics(char *devname, long 
+ 	if (!strncmp(devname, "cpu", 3)) {
+ 		fseek(fp_stat, 0, SEEK_SET);
+ 		while ((getline(&line, &line_size, fp_stat)) > 0) {
+-			if (strstr(line, "cpu ")) {
++			if (strstr(line, "cpu")) {
++				int cpu = -1; /* by default, cumul stats => average */
++				if (!strstr(line, "cpu ")) {
++					sscanf(line, "cpu%d", &cpu);
++					ds2[cpu] = 0;
++					idle2[cpu] = 0;
++				}
+ 				p = strtok(line, tokens);
+ 				/* 1..3, 4 == idle, we don't want idle! */
+ 				for (i=0; i<3; i++) {
+ 					p = strtok(NULL, tokens);
+-					*ds += atol(p);
++					if (cpu == -1)
++						*ds += atol(p);
++					else
++						ds2[cpu] += atol(p);
+ 				}
+ 				p = strtok(NULL, tokens);
+-				*idle = atol(p);
++				if (cpu == -1)
++					*idle = atol(p);
++				else
++					idle2[cpu] = atol(p);
+ 			}
+ 		}
+ 		fp_loadavg = freopen("/proc/loadavg", "r", fp_loadavg);
+@@ -676,6 +759,43 @@ void get_statistics(char *devname, long 
+ }
+ 
+ /*******************************************************************************\
++|* getWidth
++\*******************************************************************************/
++
++unsigned long getWidth(long actif, long idle) {
++	unsigned long j;
++
++	j = (actif + idle);
++	if (j != 0) {
++		j = (actif * 100) / j;
++	}
++	j = j * 0.32;
++	if (j > 32) j = 32;
++
++	return j;
++}
++
++
++/*******************************************************************************\
++|* getNbCPU																   *|
++\*******************************************************************************/
++
++int getNbCPU(void) {
++	static char *line = NULL;
++	static size_t line_size = 0;
++	int cpu = 0;
++
++	fseek(fp_stat, 0, SEEK_SET);
++	while ((getline(&line, &line_size, fp_stat)) > 0) {
++		if (strstr(line, "cpu") && !strstr(line, "cpu "))
++			sscanf(line, "cpu%d", &cpu);
++	}
++
++	return cpu+1;
++}
++
++
++/*******************************************************************************\
+ |* checksysdevs																   *|
+ \*******************************************************************************/
+ 
+@@ -806,6 +926,8 @@ void usage(char *name) {
+ 	printf("  -display DISPLAY     contact the DISPLAY X server\n");
+ 	printf("  -geometry GEOMETRY   position the clock at GEOMETRY\n");
+ 	printf("  -l                   locked view - cannot cycle modes\n");
++	printf("  -c                   show average and max CPU for SMP machine.\n");
++	printf("                       default if there is more than %d processors\n", MAX_CPU);
+ 	printf("  -i                   start in Disk I/O mode\n");
+ 	printf("  -s                   start in System Info mode\n");
+ 	printf("  -h                   display this help and exit\n");
diff --git a/debian/rules b/debian/rules
index 011dc0d..ef2ebb3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -53,7 +53,7 @@ clean:
 install: build
 	dh_testdir
 	dh_testroot
-	dh_clean -k
+	dh_clean
 	dh_installdirs
 
 	# Add here commands to install the package into debian/wmmon.
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/wmgeneral/wmgeneral.c b/wmgeneral/wmgeneral.c
index 87be712..a4f13c1 100644
--- a/wmgeneral/wmgeneral.c
+++ b/wmgeneral/wmgeneral.c
@@ -12,8 +12,6 @@
 	---
 	CHANGES:
 	---
-	10/10/2003 (Simon Law, sfllaw at debian.org)
-		* changed the parse_rcfile function to use getline instead of fgets.
 	02/05/1998 (Martijn Pieterse, pieterse at xs4all.nl)
 		* changed the read_rc_file to parse_rcfile, as suggester by Marcelo E. Magallon
 		* debugged the parse_rc file.
@@ -23,7 +21,6 @@
 
 */
 
-#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -86,18 +83,17 @@ int CheckMouseRegion(int, int);
 void parse_rcfile(const char *filename, rckeys *keys) {
 
 	char	*p;
-	char	*line = NULL;
-	size_t  line_size = 0;
+	char	temp[128];
 	char	*tokens = " :\t\n";
 	FILE	*fp;
 	int		i,key;
 
 	fp = fopen(filename, "r");
 	if (fp) {
-		while (getline(&line, &line_size, fp) >= 0) {
+		while (fgets(temp, 128, fp)) {
 			key = 0;
 			while (key >= 0 && keys[key].label) {
-				if ((p = strstr(line, keys[key].label))) {
+				if ((p = strstr(temp, keys[key].label))) {
 					p += strlen(keys[key].label);
 					p += strspn(p, tokens);
 					if ((i = strcspn(p, "#\n"))) p[i] = 0;
@@ -274,7 +270,6 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	unsigned int	borderwidth = 1;
 	XClassHint		classHint;
 	char			*display_name = NULL;
-	char			*geometry = NULL;
 	char			*wname = argv[0];
 	XTextProperty	name;
 
@@ -287,9 +282,7 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 
 	for (i=1; argv[i]; i++) {
 		if (!strcmp(argv[i], "-display")) 
-			display_name = argv[++i];
-		else if (!strcmp(argv[i], "-geometry"))
-			geometry = argv[++i];
+			display_name = argv[i+1];
 	}
 
 	if (!(display = XOpenDisplay(display_name))) {
@@ -314,11 +307,7 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	fore_pix = GetColor("black");
 
 	XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
-	            &mysizehints.x, &mysizehints.y,
-	            &mysizehints.width, &mysizehints.height, &dummy);
-	if (geometry)
-		XParseGeometry(geometry, &mysizehints.x, &mysizehints.y,
-		               &mysizehints.width, &mysizehints.height);
+				&mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
 
 	mysizehints.width = 64;
 	mysizehints.height = 64;
@@ -375,6 +364,3 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	XMapWindow(display, win);
 
 }
-
-/* vim: sw=4 ts=4 columns=82
- */
diff --git a/wmmon/wmmon.1 b/wmmon/wmmon.1
deleted file mode 100644
index 39a5e04..0000000
--- a/wmmon/wmmon.1
+++ /dev/null
@@ -1,192 +0,0 @@
-'\" t
-.\" Man page for wmmon
-.\" Copyright (c) 2003  Software in the Public Interest, Inc.
-.\"
-.\" This program 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 (at
-.\" your option) any later version.
-.\"
-.\" This program 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 program; if not, write to the Free Software
-.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-.\"
-.TH wmmon 1 "May 1998" "WMMON 1.0b2"
-
-.SH NAME
-wmmon \- Window Maker dockapp for monitoring system information
-
-.SH SYNOPSIS
-
-.B wmmon
-[
-.I OPTION
-]
-
-.SH DESCRIPTION
-
-.B WMMon
-monitors the realtime CPU load as well as the average system load,
-and gives you some nice additional features too. It is intended for
-docking in Window Maker.
-
-It currently provides:
-
-.IP \(bu 4
-a realtime CPU stress meter;
-.IP \(bu
-an auto-scaled average system load meter, like
-.B xload
-and
-.BR wmavgload ;
-.IP \(bu
-a realtime disk I/O stress meter;
-.IP \(bu
-auto-scaled disk I/O load meter;
-.IP \(bu
-realtime memory and swap usage meters;
-.IP \(bu
-a display for system uptime;
-.IP \(bu
-three user-defined commands to launch.
-
-.SH OPTIONS
-
-.TP
-.BI \-display \ display
-This option specifies the X server to contact; see
-.IR X(7x) .
-
-.TP
-.BI \-geometry \ geometry
-This option specifies the preferred position of clock; see
-.IR X(7x) .
-
-.TP
-.BR \-l
-Lock the mode, so that it cannot be cycled by clicking on the upper-left
-widget.  You can use this to open multiple copies of
-.BR WMMon ,
-each set to a different mode.
-
-.TP
-.BR \-i
-Start in disk I/O mode, which displays instantaneous disk usage and
-average disk load.
-
-.TP
-.BR \-s
-Start in system information mode, which displays memory usage, swap usage,
-and uptime.
-
-.TP
-.B \-h
-Show help information.
-
-.TP
-.B \-v
-Print the version number.
-
-.SH USAGE
-The
-.B WMMon
-display can be cycled between CPU, disk I/O, and system
-information displays by clicking on the upper-left widget.  This
-displays CPU information by default.
-
-WMMon can also be used to launch programs.  You may click either left,
-middle, or right mouse buttons in the average-load section of the
-window.  The pre-configured program will be launched according to the
-mouse button clicked.  (see
-.B CONFIGURATION FILE
-below.)
-
-In order to move
-.BR WMMon ,
-drag on the outer edges.  These are not sensitive to mouse clicks.
-
-.SH "DOCKING IN WINDOW MANAGERS"
-
-.TP
-Window Maker
-
-Window Maker users should drag and drop the
-.B WMMon
-window on the Dock.  Then, right-click on the border of the window and
-select \*(lqSettings...\*(rq.  Check \*(lqStart when Window Maker
-is started\*(rq.
-
-.TP
-AfterStep
-
-AfterStep users should put the following in their
-.I $HOME/.steprc
-
-.RS 16
-Wharf wmmon \- MaxSwallow "wmmon" wmmon &
-.RE
-
-.TP
-Other window managers
-
-.B WMMon
-runs nicely as a 64x64 shaped icon on your desktop.
-
-.SH "CONFIGURATION FILE"
-
-.B WMMon
-can launch three user-defined commands, triggered by left, middle and
-right mouse button clicks.  You can define the commands to launch in
-.I $HOME/.wmmonrc
-
-.RS
-.PD 0
-left: xterm
-.PP
-middle: xload
-.PP
-right: xcalc
-.PP
-.PD 
-.RE
-
-If
-.B WMMon
-detects a
-.I $HOME/.wmmonrc
-file, it will launch the appropriate command when you click on the clock.
-
-The system administrator can define default commands in
-.IR /etc/wmmonrc .
-The administrator may also choose to \*(lqfix\*(rq particular commands,
-making it impossible for users to change.  These commands can be defined in
-.IR /etc/wmmonrc.fixed ,
-although this isn't a nice thing to do.
-
-.SH FILES
-
-.I /etc/wmmonrc
-.br
-.I $HOME/.wmmonrc
-.br
-.I /etc/wmmonrc.fixed
-
-.SH AUTHORS
-
-.B WMMon
-was written by Martijn Pieterse and Antoine Nulle.
-
-This manual page was written by Simon Law <sfllaw at debian.org> for the
-.B Debian
-system (but may be used by others). It is based on the documentation provided
-by the original program.
-
-This manual 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 (at
-your option) any later version.
diff --git a/wmmon/wmmon.c b/wmmon/wmmon.c
index 410c2be..20fdabe 100644
--- a/wmmon/wmmon.c
+++ b/wmmon/wmmon.c
@@ -28,12 +28,6 @@
 	Changes:
 	----
 
-	15/05/2004 (Simon Law, sfllaw at debian.org)
-		* Support disabling of mode-cycling
-	23/10/2003 (Simon Law, sfllaw at debian.org)
-		* Eliminated exploitable static buffers
-		* Added -geometry support.
-		* /proc/meminfo support for Linux 2.6
 	18/05/1998 (Antoine Nulle, warp at xs4all.nl)
 		* MEM/SWAP/UPTIME only updated when visible
 		* Using global file descriptors to reduce file
@@ -71,7 +65,6 @@
 		* First Working Version
 */
 
-#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
@@ -107,28 +100,31 @@
  /* Global Variables */
 /********************/
 
+char	*ProgName;
 int	stat_current = 0; /* now global */
-int mode_cycling = 1; /* Allow mode-cycling */
 FILE	*fp_meminfo;
 FILE	*fp_stat;
 FILE	*fp_loadavg;
 
 /* functions */
-void usage(char*);
+void usage(void);
 void printversion(void);
 void DrawStats(int *, int, int, int, int);
 void DrawStats_io(int *, int, int, int, int);
 
 void wmmon_routine(int, char **);
 
-int main(int argc, char *argv[]) {
+void main(int argc, char *argv[]) {
 
 	int		i;
-	char	*name = argv[0];
 	
 
 	/* Parse Command Line */
 
+	ProgName = argv[0];
+	if (strlen(ProgName) >= 5)
+		ProgName += (strlen(ProgName) - 5);
+	
 	for (i=1; i<argc; i++) {
 		char *arg = argv[i];
 
@@ -136,17 +132,13 @@ int main(int argc, char *argv[]) {
 			switch (arg[1]) {
 			case 'd' :
 				if (strcmp(arg+1, "display")) {
-					usage(name);
-					return 1;
+					usage();
+					exit(1);
 				}
 				break;
-			case 'g' :
-				if (strcmp(arg+1, "geometry")) {
-					usage(name);
-					return 1;
-				}
-			case 'l' :
-				mode_cycling = 0;
+			case 'v' :
+				printversion();
+				exit(0);
 				break;
 			case 'i' :
 				stat_current = 1;
@@ -154,20 +146,15 @@ int main(int argc, char *argv[]) {
 			case 's' :
 				stat_current = 2;
 				break;
-			case 'v' :
-				printversion();
-				return 0;
 			default:
-				usage(name);
-				return 1;
+				usage();
+				exit(0);
+				break;
 			}
 		}
 	}
 
 	wmmon_routine(argc, argv);
-  
-      exit (0);
-   
 }
 
 /*******************************************************************************\
@@ -227,7 +214,8 @@ void wmmon_routine(int argc, char **argv) {
 	long		idle;
 
 	FILE		*fp;
-	char		*conffile = NULL;
+	char		temp[128];
+	char		*p;
 
 	int			xpm_X = 0, xpm_Y = 0;
 
@@ -258,21 +246,16 @@ void wmmon_routine(int argc, char **argv) {
 	if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION);
 	if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION);
 
-	/* Scan through the .rc files */
-	if (asprintf(&conffile, "/etc/wmmonrc") >= 0) {
-		parse_rcfile(conffile, wmmon_keys);
-		free(conffile);
-	}
+	strcpy(temp, "/etc/wmmonrc");
+	parse_rcfile(temp, wmmon_keys);
 
-	if (asprintf(&conffile, "%s/.wmmonrc", getenv("HOME")) >= 0) {
-		parse_rcfile(conffile, wmmon_keys);
-		free(conffile);
-	}
-
-	if (asprintf(&conffile, "/etc/wmmonrc.fixed") >= 0) {
-		parse_rcfile(conffile, wmmon_keys);
-		free(conffile);
-	}
+	p = getenv("HOME");
+	strcpy(temp, p);
+	strcat(temp, "/.wmmonrc");
+	parse_rcfile(temp, wmmon_keys);
+	
+	strcpy(temp, "/etc/wmmonrc.fixed");
+	parse_rcfile(temp, wmmon_keys);
 
 	stat_online = checksysdevs();
 
@@ -286,36 +269,26 @@ void wmmon_routine(int argc, char **argv) {
 	starttime = time(0);
 	nexttime = starttime + 10;
 
-	/* Collect information on each panel */
 	for (i=0; i<stat_online; i++) {
 		get_statistics(stat_device[i].name, &k, &istat, &idle);
 		stat_device[i].statlast = istat;
 		stat_device[i].idlelast = idle;
 	}
-
-	/* Set the mask for the current window */
-	switch (stat_current) {
-		case 0:
-		case 1:
-			xpm_X = 0;
-			setMaskXY(0, 0);
-			break;
-		case 2:
-			xpm_X = 64;
-			setMaskXY(-64, 0);
-		default:
-			break;
-	}
-
-	/* Draw statistics */
-	if (stat_current == 0)
-		DrawStats(stat_device[stat_current].his, 54, 40, 5, 58);
-	if (stat_current == 1)
+	if (stat_current == 0) DrawStats(stat_device[stat_current].his, 54, 40, 5, 58);
+	if (stat_current == 1) {
 		DrawStats_io(stat_device[stat_current].his, 54, 40, 5, 58);
+	}
+	if (stat_current == 2) {
+		xpm_X = 64;
+		setMaskXY(-64, 0);
+	} else {
+		xpm_X = 0;
+		setMaskXY(0, 0);
+	}
 	DrawActive(stat_device[stat_current].name);
 
 	while (1) {
-		curtime = time(NULL);
+		curtime = time(0);
 
 		waitpid(0, NULL, WNOHANG);
 
@@ -404,9 +377,6 @@ void wmmon_routine(int argc, char **argv) {
 		if (curtime >= nexttime) {
 			nexttime+=10;
 
-			if (curtime > nexttime) /* dont let APM suspends make this crazy */
-			  nexttime = curtime;
-
 			for (i=0; i<stat_online; i++) {
 				if (stat_device[i].his[54])
 					stat_device[i].his[54] /= stat_device[i].hisaddcnt;
@@ -441,7 +411,7 @@ void wmmon_routine(int argc, char **argv) {
 				break;
 			case ButtonRelease:
 				i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
-				if (but_stat == i && but_stat >= 0 && mode_cycling) {
+				if (but_stat == i && but_stat >= 0) {
 					switch (but_stat) {
 					case 0:
 						switch (Event.xbutton.button) {
@@ -460,6 +430,7 @@ void wmmon_routine(int argc, char **argv) {
 						}
 					case 1:
 						stat_current++;
+						printf("current stat is :%d\n", stat_current);
 						if (stat_current == stat_online)
 							stat_current = 0;
 
@@ -528,80 +499,43 @@ void update_stat_io(stat_dev *st) {
 
 void update_stat_mem(stat_dev *st, stat_dev *st2) {
 
-	static char *line = NULL;
-	static size_t line_size = 0;
-
-	unsigned long swapfree;
+	char	temp[128];
 	unsigned long free, shared, buffers, cached;
 
 	freopen("/proc/meminfo", "r", fp_meminfo);
-	while ((getline(&line, &line_size, fp_meminfo)) > 0) {
-		/* The original format for the first two lines of /proc/meminfo was
-		 * Mem: total used free shared buffers cached
-		 * Swap: total used free
-		 *
-		 * As of at least 2.5.47 these two lines were removed, so that the
-		 * required information has to come from the rest of the lines.
-		 * On top of that, used is no longer recorded - you have to work
-		 * this out yourself, from total - free.
-		 *
-		 * So, these changes below should work. They should also work with
-		 * older kernels, too, since the new format has been available for
-		 * ages.
-		 */
-		if (strstr(line, "MemTotal:")) {
-			sscanf(line, "MemTotal: %ld", &st->rt_idle);
-		}
-		else if (strstr(line, "MemFree:")) {
-			sscanf(line, "MemFree: %ld", &free);
-		}
-		else if (strstr(line, "MemShared:")) {
-			sscanf(line, "MemShared: %ld", &shared);
-		}
-		else if (strstr(line, "Buffers:")) {
-			sscanf(line, "Buffers: %ld", &buffers);
-		}
-		else if (strstr(line, "Cached:")) {
-			sscanf(line, "Cached: %ld", &cached);
-		}
-		else if (strstr(line, "SwapTotal:")) {
-			sscanf(line, "SwapTotal: %ld", &st2->rt_idle);
+	while (fgets(temp, 128, fp_meminfo)) {
+		if (strstr(temp, "Mem:")) {
+			sscanf(temp, "Mem: %ld %ld %ld %ld %ld %ld",
+			       &st->rt_idle, &st->rt_stat,
+			       &free, &shared, &buffers, &cached);
+			st->rt_idle >>= 10;
+			st->rt_stat -= buffers+cached;
+			st->rt_stat >>= 10;
+//			break;
 		}
-		else if (strstr(line, "SwapFree:")) {
-			sscanf(line, "SwapFree: %ld", &swapfree);
+		if (strstr(temp, "Swap:")) {
+			sscanf(temp, "Swap: %ld %ld", &st2->rt_idle, &st2->rt_stat);
+			st2->rt_idle >>= 10;
+			st2->rt_stat >>= 10;
+			break;
 		}
 	}
-
-	/* memory use - rt_stat is the amount used, it seems, and this isn't
-	 * recorded in current version of /proc/meminfo (as of 2.5.47), so we
-	 * calculate it from MemTotal - MemFree
-	 */
-	st->rt_stat = st->rt_idle - free;
-	st->rt_stat -= buffers+cached;
-	/* As with the amount of memory used, it's not recorded any more, so
-	 * we have to calculate it ourselves.
-	 */
-	st2->rt_stat = st2->rt_idle - swapfree;
 }
 
 void update_stat_swp(stat_dev *st) {
 
-	static char *line = NULL;
-	static size_t line_size = 0;
-	unsigned long swapfree;
+	char	temp[128];
 
 	fseek(fp_meminfo, 0, SEEK_SET);
-	while ((getline(&line, &line_size, fp_meminfo)) > 0) {
-		/* As with update_stat_mem(), the format change to /proc/meminfo has
-		 * forced some changes here. */
-		if (strstr(line, "SwapTotal:")) {
-			sscanf(line, "SwapTotal: %ld", &st->rt_idle);
-		}
-		else if (strstr(line, "SwapFree:")) {
-			sscanf(line, "SwapFree: %ld", &swapfree);
+	while (fgets(temp, 128, fp_meminfo)) {
+		if (strstr(temp, "Swap:")) {
+			sscanf(temp, "Swap: %ld %ld", &st->rt_idle, &st->rt_stat);
+			st->rt_idle >>= 10;
+			st->rt_stat >>= 10;
+			break;
 		}
 	}
-	st->rt_stat = st->rt_idle - swapfree;
+
 }
 
 /*******************************************************************************\
@@ -611,11 +545,11 @@ void update_stat_swp(stat_dev *st) {
 void get_statistics(char *devname, long *is, long *ds, long *idle) {
 
 	int	i;
-	static char *line = NULL;
-	static size_t line_size = 0;
+	char	temp[128];
 	char	*p;
 	char	*tokens = " \t\n";
 	float	f;
+	long	maxdiskio=0;
 
 	*is = 0;
 	*ds = 0;
@@ -623,9 +557,9 @@ void get_statistics(char *devname, long *is, long *ds, long *idle) {
 
 	if (!strncmp(devname, "cpu", 3)) {
 		fseek(fp_stat, 0, SEEK_SET);
-		while ((getline(&line, &line_size, fp_stat)) > 0) {
-			if (strstr(line, "cpu ")) {
-				p = strtok(line, tokens);
+		while (fgets(temp, 128, fp_stat)) {
+			if (strstr(temp, "cpu")) {
+				p = strtok(temp, tokens);
 				/* 1..3, 4 == idle, we don't want idle! */
 				for (i=0; i<3; i++) {
 					p = strtok(NULL, tokens);
@@ -643,35 +577,17 @@ void get_statistics(char *devname, long *is, long *ds, long *idle) {
 	if (!strncmp(devname, "i/o", 3)) {
 
 		fseek(fp_stat, 0, SEEK_SET);
-		while ((getline(&line, &line_size, fp_stat)) > 0) {
-			if (strstr(line, "disk_rio") || strstr(line, "disk_wio")) {
-				p = strtok(line, tokens);
+		while (fgets(temp, 128, fp_stat)) {
+			if (strstr(temp, "disk_rio") || strstr(temp, "disk_wio")) {
+				p = strtok(temp, tokens);
 				/* 1..4 */
 				for (i=0; i<4; i++) {
 					p = strtok(NULL, tokens);
 					*ds += atol(p);
 				}
 			}
-			else if (strstr(line, "disk_io")) {
-				int val;
-				unsigned int a, b, c, d, e, h, g;
-   
-				p = strtok(line, tokens);
-   
-				while ((p = strtok(NULL, tokens))) {
-					val = sscanf (p,
-						      "(%d,%d):(%d,%d,%d,%d,%d)",
-						      &a, &b, &c, &d, &e, &h,
-						      &g);
-   
-					if (val != 7)
-						continue;
-   
-					*ds += d;
-					*ds += h;
-				}
-			}
 		}
+		if (*ds > maxdiskio) maxdiskio = *ds;
 	}
 }
 
@@ -799,17 +715,16 @@ void DrawStats_io(int *his, int num, int size, int x_left, int y_bottom) {
 |* usage																	   *|
 \*******************************************************************************/
 
-void usage(char *name) {
-	printf("Usage: %s [OPTION]...\n", name);
-	printf("WindowMaker dockapp that displays system information.\n");
-	printf("\n");
-	printf("  -display DISPLAY     contact the DISPLAY X server\n");
-	printf("  -geometry GEOMETRY   position the clock at GEOMETRY\n");
-	printf("  -l                   locked view - cannot cycle modes\n");
-	printf("  -i                   start in Disk I/O mode\n");
-	printf("  -s                   start in System Info mode\n");
-	printf("  -h                   display this help and exit\n");
-	printf("  -v                   output version information and exit\n");
+void usage(void) {
+
+	fprintf(stderr, "\nwmmon - programming: tijno, (de)bugging & design warp, webhosting: bobby\n\n");
+	fprintf(stderr, "usage:\n");
+	fprintf(stderr, "\t-display <display name>\n");
+	fprintf(stderr, "\t-h\tthis screen\n");
+	fprintf(stderr, "\t-v\tprint the version number\n");
+	fprintf(stderr, "\t-i\tstartup in DiskIO mode\n");
+	fprintf(stderr, "\t-s\tstartup in SysInfo mode\n");
+	fprintf(stderr, "\n");
 }
 
 /*******************************************************************************\
@@ -818,7 +733,7 @@ void usage(char *name) {
 
 void printversion(void) {
 
-	printf("WMMon version %s\n", WMMON_VERSION);
+	if (!strcmp(ProgName, "wmmon")) {
+		fprintf(stderr, "%s\n", WMMON_VERSION);
+	}
 }
-/* vim: sw=4 ts=4 columns=82
- */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmmon.git



More information about the Pkg-wmaker-commits mailing list