wmcpuload: Bump to version 1.1.0pre5.

Obtained from http://distfiles.gentoo.org/distfiles/wmcpuload-1.1.0pre5.tar.gz
This commit is contained in:
Doug Torrance 2016-10-20 10:17:39 -04:00 committed by Carlos R. Mafra
parent d606c50961
commit e85e0559c3
29 changed files with 540 additions and 333 deletions

View file

@ -1,10 +1,12 @@
$Id: AUTHORS,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
Main Author:
Seiichi SATO <ssato@sh.rim.or.jp>
Solaris port:
Jonathan Lang <lang@synopsys.com>
Writting manpage:
Man-page:
Gordon Fraser <gordon@debian.org>
NetBSD port:
@ -12,3 +14,9 @@ Thomas Runge <coto@core.de>
BSDi port:
Nicolas Belan <belan@matranet.com>
IRIX port:
Jonathan C. Patschke <jp@celestrion.net>
Darwin port:
Landon Fuller <landonblue@mac.com>

View file

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -303,16 +303,17 @@ the "copyright" line and a pointer to where the full notice is found.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@ -335,5 +336,5 @@ necessary. Here is a sample; alter the names:
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View file

@ -1,3 +1,57 @@
$Id: ChangeLog,v 1.9 2006-01-28 10:40:06 sch Exp $
2006 Jan 28
* cpu_linux.c:
* main.c:
applied a patch from php-coder <php-coder at altlinux.ru>
2005 Feb 12
* main.c: clear digits before redraw_digit().
2005 Feb 10
* cpu_linux.c:
- supported linux 2.6
- remvoed --ignore-proc.
* configure.ac: remvoed --ignore-proc.
* main.c: remvoed --ignore-proc.
2005 Jan 17
* configure.ac: fixed a typo.
2004 Feb 1
* src/cpu_freebsd.c: fixed a bug with --ignore-nice option.
2004 Jan 25
* libdockapp/dockapp.c (dockapp_win): added.
* src/main.c: ExposureMask
* src/main.c: removed pixmap buffering for optimization.
2003 Oct 12
* src/cpu_openbsd.c, src/cpu_netbsd.c: fixed a bug with --ignore-nice option.
(Thanks to Nedko Arnaudov <nedko at users.sourceforge.net> for sending a
patch)
2003 Mar 9
* version 1.0.1 released
2003 Mar 8
* src/cpu_freebsd.c: changed to use <sys/resource.h> instead of <sys/dkstat.h>
in the case of __FreeBSD_version >= 500101.
(Thanks to Philip Paeps <philip at paeps.cx)
2002 Sep 29
* doc/wmcpuload.1: updated
2002 Sep 25
* cpu_darwin.c: added (Landon Fuller <landonblue at mac.com>)
2002 Sep 1
* main.c: changed description for `--cpu' oprion to be more clear.
* README: updated
2002 Aug 20
* cpu_irix.c: added for IRIX (Jonathan C. Patschke <jp at celestrion.net>)
2002 Jul 14
* version 1.0.0 released
@ -11,13 +65,13 @@
* src/Makefile.am: added missing @DFLAGS@
2002 May 17
* cpu_bsdi.c: added (Nicolas Belan <belan@matranet.com>)
* cpu_bsdi.c: added (Nicolas Belan <belan at matranet.com>)
2002 April 09
* dockapp.c, dockapp.h: moved to libdockapp/dockapp.[ch]
* libdockapp/{COPYING,AUTHORS}: added (taken from libdockapp-0.4.0)
* configure.ac: removed '-L/usr/local/lib' '-I/usr/local/include' from
*_search_path (Thanks to Thomas Runge <coto@core.de>)
*_search_path (Thanks to Thomas Runge <coto at core.de>)
* README: added 'for GNOME users' section
2002 April 05
@ -28,7 +82,7 @@
* dockapp.c: removed background panel from windowed mode.
* dockapp.c: added '-wp, --windowed-withpanel' option.
* main.c: added '-t, --title' option to specify title name
(Thanks to Ryan Lovett <ryan@ocf.berkeley.edu>)
(Thanks to Ryan Lovett <ryan at ocf.berkeley.edu>)
* wmcpuload.1: updated
* cpu_netbsd.c: added 'CP_INTR' parameter
@ -165,7 +219,7 @@
2001 July 23
* version 0.5.6 released
* changed to get rid of compiler warning messages with gcc
* changed to get rid of compiler warning messages with gcc
on Linux and FreeBSD.
* added OpenBSD support (it's testing!!)
(john katagawa <dhc at scurvy.org>)

View file

@ -1,12 +1,13 @@
$Id: INSTALL,v 1.2 2003-04-06 09:12:41 sch Exp $
Supported Platforms:
====================
(ie: I've heard someone has compiled it on...)
- GNU/Linux Redhat 7.0, 7.1, 7.2, 7.3 (x86)
- GNU/Linux Redhat 7.0, 7.1, 7.2, 7.3, 8.0 (x86)
- GNU/Linux Mandrake 7.2, 8.0, 8.1, 8.2 (x86, ppc)
- Debian GNU/Linux 2.2 potato (x86)
- Debian GNU/Linux woody/sid
- Debian GNU/Linux 3.0 woody, sarge, sid
(x86, alpha, arm, hppa, ia64, m68k, mips, ppc, s390, sparc)
- GNU/Linux SuSE 7.0, 7.1 (x86)
- GNU/Linux Gentoo 1.0, 1.0a (x86, powerpc)
@ -14,11 +15,13 @@ Supported Platforms:
- FreeBSD 4-STABLE (x86, alpha)
- FreeBSD 5-CURRENT (x86, alpha)
- OpenBSD 2.9 (x86)
- NetBSD-current (x86, amigappc, bebox, macppc, powerpc, prep, vax)
- NetBSD 1.5 (x86, amigappc, bebox, macppc, powerpc, prep, vax)
- BSDi 4.1
- Solaris 7, 8
- Cygwin 1.3.3 / Windows 98, Me
- Cygwin 1.3.10 / Windows 98, Me, 2000
- IRIX 6.5
- Darwin 6.0.1
Patches to make it work on other platforms are welcome.

View file

@ -1,2 +1,3 @@
# $Id: Makefile.am,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
SUBDIRS = src libdockapp icons contrib doc

View file

@ -1,3 +1,5 @@
# $Id: NEWS,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
Overview of Changes in WMCPULoad 0.9.0:

View file

@ -1,3 +1,5 @@
$Id: README,v 1.6 2003-06-29 14:34:32 sch Exp $
WMCPULoad - A dockapp to monitor CPU usage
General Information
@ -11,7 +13,8 @@ LCD look-alike user interface. The back-light may be turned on/off by clicking
the mouse button over the application. If the CPU usage hits a certain
threshold, an alarm-mode will alert you by turning back-light on.
It runs on GNU/Linux / FreeBSD / OpenBSD / NetBSD / BSDi / Solaris / Cygwin.
It runs on GNU/Linux / FreeBSD / OpenBSD / NetBSD / BSDi / Solaris / Cygwin /
IRIX / Darwin .
Installation
============
@ -31,7 +34,7 @@ $ wmcpuload [OPTIONS]
-bl, --backlight turn on back-light
-lc, --light-color <color> back-light color (rgb:6E/C6/3B is default)
-i, --interval <number> number of secs between updates (1 is default)
-c, --cpu <number> CPU number (0, 1, ...)
-c, --cpu <number> which CPU is monitored (0, 1, ...)
-n, --ignore-nice ignore a nice value
-p, --ignore-proc <name><...> ignore all processes specified by command name
-h, --help show this help text and exit
@ -46,12 +49,12 @@ $ wmcpuload [OPTIONS]
NOTES:
- '-n, --ignore-nice' option is activated under GNU/Linux / {Free,Open,Net}BSD.
- '-p, --ignore-proc' option is activated under GNU/Linux.
- '-c, --cpu' option is activated under GNU/Linux.
- '-c, --cpu' option is activated under GNU/Linux / IRIX.
For AfterStep users
===================
Add below entry to your Wharf
Add this line to your ~/GNUstep/Library/AfterStep/wharf:
*Wharf wmcpuload - Swallow "wmcpuload" wmcpuload -w &
@ -66,8 +69,7 @@ open 'Create swallow Applet' dialog and enter the values as below.
3. width: 62
4. height: 62
NOTE: You can't run swallowed application with sawfish 1.0.1. This problem has
fixed in current cvs.
NOTE: GNOME2 does not support the swallowed application.
For Enlightenment users
@ -77,7 +79,7 @@ Use '-bw, --broken-wm' option.
For Golem users
===============
Add below entry to your ~/.golem/plugins/pier/rc
Add following entry to your ~/.golem/plugins/pier/rc
param "item" "dock" {
param "cmd" "exec wmcpuload";
@ -91,7 +93,7 @@ Frequently Asked Questions
Q) Which window managers do support dockapps?
A) - Window Maker http://www.windowmaker.org/
- AfterStep http://www.afterstep.org/
- Blackbox http://blackbox.alug.org/
- Blackbox http://blackboxwm.sourceforge.net/
- Enlightenment http://www.enlightenment.org/
- Fluxbox http://fluxbox.sourceforge.net/
- Waimea http://waimea.sourceforge.net/

View file

@ -1,3 +1,5 @@
$Id: TODO,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
* optimize drawing-routines (MIT-SHM)
* other OS support (Mac OS X, HP-UX, IRIX, AIX ...)
* other OS support (HP-UX, AIX ...)
* multiprocessors support on Solaris, FreeBSD, NetBSD, OpenBSD and BSDi

View file

@ -1,9 +1,11 @@
dnl $Id: configure.ac,v 1.6 2006-01-28 10:40:37 sch Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(wmcpuload, 0.9.0)
AC_INIT(wmcpuload, 1.0.0, ssato@sh.rim.or.jp)
AC_INIT(wmcpuload, 1.1.0pre5, ssato@sh.rim.or.jp)
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
@ -89,15 +91,13 @@ dnl Determine OS
dnl ============
ignore_nice=no
ignore_proc=no
use_smp=no
case ${target_os} in
linux*)
OS=linux
ignore_nice=yes
ignore_proc=yes
AC_CHECK_HEADER(linux/threads.h, [AC_DEFINE(USE_SMP, 1, [use SMP support])],
[echo "linux/threads.h header file was not found, but is necessary to support mulit processors"])
use_smp=yes
;;
freebsd*)
OS=freebsd
@ -124,6 +124,13 @@ solaris*)
cygwin*)
OS=cygwin
;;
irix*)
OS=irix
use_smp=yes
;;
darwin*)
OS=darwin
;;
*)
echo ""
echo "Sorry, ${target_os} is not supported yet"
@ -139,8 +146,8 @@ AC_SUBST(LIBS)
if test "$ignore_nice" = yes; then
AC_DEFINE(IGNORE_NICE, 1, [use '--ignore-nice' option])
fi
if test "$ignore_proc" = yes; then
AC_DEFINE(IGNORE_PROC, 1, [use '--ignore-process' option])
if test "$use_smp" = yes; then
AC_DEFINE(USE_SMP, 1, [use SMP support])
fi

View file

@ -1,3 +1,4 @@
# $Id: Makefile.am,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
EXTRA_DIST = README wmcpuload.spec.in

View file

@ -1,3 +1,5 @@
$Id: README,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
*** wmcpuload.spec
author:

View file

@ -1,3 +1,4 @@
# $Id: Makefile.am,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
man_MANS = wmcpuload.1

View file

@ -1,3 +1,4 @@
.\" $Id: wmcpuload.1,v 1.2 2005-02-10 01:13:40 sch Exp $
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@ -26,7 +27,7 @@ command.
This manual page was written for the Debian GNU/Linux distribution.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBWMCPULoad\fP is a dockapp that is supported by X window managers such as
Window Maker, AfterStep, BlackBox, and Enlightenment. It displays the current
@ -57,7 +58,7 @@ back-light color (rgb:6E/C6/3B is default)
.B \-i, \-\-interval <number>
number of secs between updates (1 is default)
.TP
.B \-c, \-\-cpu <number>
.B \-c, \-\-cpu <number> (GNU/Linux / IRIX)
CPU number to monitor (Counting starts with 0).
.TP
.B \-n, \-\-ignore\-nice (GNU/Linux / FreeBSD / OpenBSD / NetBSD)
@ -80,9 +81,6 @@ activate broken window manager fix
.TP
.B \-a, \-\-alarm <percentage>
activate alarm mode. <percentage> is threshold of percentage from 0 to 100.(90 is default)
.TP
.B \-p, \-\-ignore\-proc <name><...>
ignore all processes specified by command name
.SH AUTHOR
WMCPULoad was written by Seiichi SATO <ssato@sh.rim.or.jp>.

View file

@ -1,3 +1,5 @@
# $Id: Makefile.am,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
EXTRA_DIST = \
wmcpuload-16x16.xpm \
wmcpuload-32x32.xpm \

View file

@ -1 +1,3 @@
$Id: README,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
Icons for Mandrake GNU/Linux

View file

@ -1,3 +1,5 @@
/* $Id: dockapp.c,v 1.3 2004-01-25 14:06:27 sch Exp $ */
/*
* Copyright (c) 1999 Alfredo K. Kojima
*
@ -261,22 +263,39 @@ void
dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src, int w, int h,
int x_dist, int y_dist)
{
Window win;
win = dockapp_isbrokenwm ? window : icon_window;
if (src == win) {
x_src += offset_w;
y_src += offset_h;
}
if (dist == win) {
x_dist += offset_w;
y_dist += offset_h;
}
XCopyArea(display, src, dist, gc, x_src, y_src, w, h, x_dist, y_dist);
}
void
dockapp_copy2window (Pixmap src)
dockapp_copy2window(Pixmap src, int x_src, int y_src, int w, int h, int x_dist,
int y_dist)
{
if (dockapp_isbrokenwm) {
XCopyArea(display, src, window, gc, 0, 0, width, height, offset_w,
offset_h);
} else {
XCopyArea(display, src, icon_window, gc, 0, 0, width, height, offset_w,
offset_h);
}
Window win;
win = dockapp_isbrokenwm ? window : icon_window;
XCopyArea(display, src, win, gc, x_src, y_src, w, h, offset_w + x_dist,
offset_h + y_dist);
}
Window
dockapp_win(void)
{
return dockapp_isbrokenwm ? window : icon_window;
}
Bool
dockapp_nextevent_or_timeout(XEvent *event, unsigned long miliseconds)
@ -457,3 +476,5 @@ dockapp_blendedcolor(char *color_name, int r, int g, int b, float fac)
return color.pixel;
}
/* ex:set sw=4 softtabstop=4: */

View file

@ -1,3 +1,5 @@
/* $Id: dockapp.h,v 1.3 2004-01-25 14:06:27 sch Exp $ */
/*
* Copyright (c) 1999 Alfredo K. Kojima
*
@ -98,7 +100,8 @@ Pixmap dockapp_XCreatePixmap(int w, int h);
void dockapp_setshape(Pixmap mask, int x_ofs, int y_ofs);
void dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src,
int w, int h, int x_dist, int y_dist);
void dockapp_copy2window(Pixmap src);
void dockapp_copy2window(Pixmap src, int x_src, int y_src, int w, int h,
int x_dist, int y_dist);
Bool dockapp_nextevent_or_timeout(XEvent * event, unsigned long miliseconds);

View file

@ -1,3 +1,5 @@
# $Id: Makefile.am,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $
bin_PROGRAMS = wmcpuload
wmcpuload_SOURCES = \
@ -15,7 +17,9 @@ EXTRA_wmcpuload_SOURCES = \
cpu_netbsd.c \
cpu_bsdi.c \
cpu_solaris.c \
cpu_cygwin.c
cpu_cygwin.c \
cpu_irix.c \
cpu_darwin.c
wmcpuload_DEPENDENCIES = ../libdockapp/dockapp.o

View file

@ -1,3 +1,5 @@
/* $Id: cpu.h,v 1.3 2005-02-10 01:12:49 sch Exp $ */
/*
* cpu.h - header file of the module to get cpu usage
*
@ -13,13 +15,11 @@
#define COMM_LEN 16
#endif
#define MAX_PROC 5
#define MAX_CPU 99
typedef struct _cpu_options {
int ignore_nice;
int cpu_number;
char *ignore_proc_list[MAX_PROC];
int ignore_procs;
} cpu_options;
void cpu_init(void);

View file

@ -1,3 +1,5 @@
/* $Id: cpu_bsdi.c,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $ */
/*
* cpu_bsdi - module to get cpu usage, for BSDi
*

View file

@ -1,3 +1,5 @@
/* $Id: cpu_cygwin.c,v 1.2 2005-02-10 01:15:21 sch Exp $ */
/*
* cpu_cygwin.c - module to get cpu usage, for Cygwin
*
@ -99,7 +101,7 @@ cpu_get_usage_9x(cpu_options *opts)
if (RegOpenKeyEx(HKEY_DYN_DATA, "PerfStats\\StatData",
0, KEY_READ, &hkeyr) != ERROR_SUCCESS) {
fprintf(stderr, "%s: can't open registry 'PerfStats\\StatData'\n", PACKAGE);
fprintf(stderr, "%s: could not open registry 'PerfStats\\StatData'\n", PACKAGE);
return 0;
}
@ -150,14 +152,14 @@ cpu_get_usage_NT(cpu_options *opts)
SYSTEM_PERFORMANCE_INFORMATION spi;
if ((h_ntdll = LoadLibraryEx("NTDLL.DLL", NULL, 0)) == NULL) {
fprintf(stderr, "%s: can't load NTDLL.DLL\n", PACKAGE);
fprintf(stderr, "%s: could not load NTDLL.DLL\n", PACKAGE);
exit (1);
}
NtQuerySystemInformation = GetProcAddress(h_ntdll,
"NtQuerySystemInformation");
if (!NtQuerySystemInformation) {
fprintf(stderr, "%s: can't find NtQuerySystemInformation()\n", PACKAGE);
fprintf(stderr, "%s: could not find NtQuerySystemInformation()\n", PACKAGE);
FreeLibrary(h_ntdll);
return 0;
}

View file

@ -0,0 +1,60 @@
/* $Id: cpu_darwin.c,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $ */
/*
* cpu_darwin - module to get cpu usage, for Darwin
*
* Copyright (C) 2002 Landon Fuller <landonblue@mac.com>
*
* Licensed under the GPL
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "cpu.h"
#include <mach/host_info.h>
#include <mach/mach_types.h>
#include <mach/message.h>
static host_cpu_load_info_data_t prevcount, curcount;
static mach_port_t host_priv_port;
static
getload(host_cpu_load_info_t cpucounters)
{
mach_msg_type_number_t count;
kern_return_t kr;
count = HOST_CPU_LOAD_INFO_COUNT;
kr = host_statistics (host_priv_port, HOST_CPU_LOAD_INFO, (host_info_t) cpucounters, &count);
return (kr);
}
void
cpu_init(void)
{
host_priv_port = mach_host_self();
getload(&prevcount);
return;
}
/* Returns the current CPU usage in percent */
int
cpu_get_usage(cpu_options *opts)
{
double userticks, systicks, idleticks, totalticks, usedticks;
getload(&curcount);
userticks = curcount.cpu_ticks[CPU_STATE_USER] - prevcount.cpu_ticks[CPU_STATE_USER];
systicks = curcount.cpu_ticks[CPU_STATE_SYSTEM] - prevcount.cpu_ticks[CPU_STATE_SYSTEM];
idleticks = curcount.cpu_ticks[CPU_STATE_IDLE] - prevcount.cpu_ticks[CPU_STATE_IDLE];
prevcount = curcount;
usedticks = userticks + systicks;
totalticks = usedticks + idleticks;
return ((100 * (double) usedticks) / totalticks);
}

View file

@ -1,7 +1,9 @@
/* $Id: cpu_freebsd.c,v 1.3 2004-02-01 10:49:53 sch Exp $ */
/*
* cpu_freebsd.c - module to get cpu usage, for FreeBSD
*
* Copyright (c) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp>
* Copyright (c) 2001, 2002, 2004 Seiichi SATO <ssato@sh.rim.or.jp>
*
* Licensed under the GPL
*/
@ -18,7 +20,14 @@
#include <kvm.h>
#include <fcntl.h>
#include <sys/dkstat.h>
#include <sys/param.h>
#if __FreeBSD_version < 500101
# include <sys/dkstat.h>
#else
# include <sys/resource.h>
#endif /* __FreeBSD_version < 500101 */
static kvm_t *kd = NULL;
static struct nlist nlst[] = { {"_cp_time"}, {0} };
@ -63,20 +72,18 @@ cpu_get_usage(cpu_options *opts)
sizeof(cpu_time))
return 0;
used = cpu_time[CP_USER] + cpu_time[CP_SYS];
if (!opts->ignore_nice)
used += cpu_time[CP_NICE];
total = used + cpu_time[CP_IDLE];
if (pre_total == 0) {
/* calculate usage */
total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
cpu_time[CP_NICE] + cpu_time[CP_IDLE];
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
(opts->ignore_nice ? 0 : cpu_time[CP_NICE]);
if ((pre_total == 0) || !(total - pre_total > 0)) {
result = 0;
} else if ((total - pre_total) > 0) {
result = (100 * (double) (used - pre_used)) / (double) (total -
pre_total);
} else {
result = 0;
result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
}
/* save used/total for next calculation */
pre_used = used;
pre_total = total;

83
wmcpuload/src/cpu_irix.c Normal file
View file

@ -0,0 +1,83 @@
/* $Id: cpu_irix.c,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $ */
/*
* cpu_irix.c - module to get cpu usage, for IRIX 6.5 and IRIX64 6.5
*
* Copyright (C) 2002 Jonathan C. Patschke <jp@celestrion.net>
* Copyright (C) 2002 Seiichi SATO <ssato@sh.rim.or.jp>
*
* licensed under the GPL
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "cpu.h"
#include <sys/types.h>
#include <sys/sysmp.h>
#include <sys/sysinfo.h>
#include <sys/sysget.h>
int cpuCount;
void
cpu_init(void)
{
cpuCount = (int)sysmp(MP_NPROCS);
return;
}
/* returns current CPU usage in percent */
int
cpu_get_usage(cpu_options *opts)
{
struct sgt_cookie cookie;
struct sysinfo info;
long cpuload, cputotal;
static long ocpuload, ocputotal;
int result, i;
if (opts->cpu_number >= cpuCount) return 0;
SGT_COOKIE_INIT(&cookie);
if (opts->cpu_number < 1) {
/* Get stats for all CPUs */
cpuload = 0;
cputotal = 0;
for (i = 0 ; i < cpuCount ; i++) {
SGT_COOKIE_SET_CPU(&cookie, i);
memset(((void *)&info), 0x00, sizeof(info));
sysget(SGT_SINFO_CPU, ((char *)&info), sizeof(info),
SGT_READ, &cookie);
cpuload += info.cpu[CPU_USER] + info.cpu[CPU_KERNEL] +
info.cpu[CPU_WAIT] + info.cpu[CPU_SXBRK] +
info.cpu[CPU_INTR];
cputotal += cpuload + info.cpu[CPU_IDLE];
};
} else {
SGT_COOKIE_SET_CPU(&cookie, opts->cpu_number);
memset(((void *)&info), 0x00, sizeof(info));
sysget(SGT_SINFO_CPU, ((char *)&info), sizeof(info),
SGT_READ, &cookie);
cpuload = info.cpu[CPU_USER] + info.cpu[CPU_KERNEL] +
info.cpu[CPU_WAIT] + info.cpu[CPU_SXBRK] +
info.cpu[CPU_INTR];
cputotal = cpuload + info.cpu[CPU_IDLE];
}
#ifdef DEBUG
fprintf(stderr, "!!!%d/%d: %d, %d, %d, %d, %d, %d\n", opts->cpu_number,
cpuCount, info.cpu[CPU_USER], info.cpu[CPU_KERNEL], info.cpu[CPU_WAIT],
info.cpu[CPU_SXBRK], info.cpu[CPU_INTR], info.cpu[CPU_IDLE]);
#endif
result = ((cpuload - ocpuload) * 100) / (cputotal - ocputotal);
ocpuload = cpuload;
ocputotal = cputotal;
return result;
}

View file

@ -1,11 +1,27 @@
/*
* cpu_linux.c - module to get cpu usage, for GNU/Linux
* wmcpuload
* GNU/Linux specific part
*
* Copyright (C) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp>
* Copyright (C) 2001, 2002, 2005 Seiichi SATO <ssato@sh.rim.or.jp>
*
* licensed under the GPL
* 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.
*/
/* $Id: cpu_linux.c,v 1.4 2006-01-28 10:40:09 sch Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -21,156 +37,97 @@
#include <sys/stat.h>
#include <linux/limits.h>
#ifdef USE_SMP
#include <linux/threads.h>
#endif
static int is_linux26;
static void set_pidlist_from_namelist(int names, char **name_list);
static int get_cpuusage_bypid(pid_t pid);
static int *pid_list;
static int pids;
void cpu_init(void)
static void
skip_line(FILE *fp)
{
/* You don't need initialization under GNU/Linux */
return;
int c;
while ((c = fgetc(fp)) != '\n')
if (c == EOF) break;
}
void
cpu_init(void)
{
unsigned long long softirq;
FILE *fp;
if (!(fp = fopen("/proc/stat", "r"))) {
perror("fopen");
exit(1);
}
is_linux26 = fscanf(fp, "%*s %*u %*u %*u %*u %*u %*u %llu",
&softirq);
fclose(fp);
return;
}
/* returns current cpu usage in percent */
int
cpu_get_usage(cpu_options *opts)
cpu_get_usage(cpu_options * opts)
{
static int pre_used, pre_total;
static int pre_ig_used;
int usage;
int cpu, nice, system, idle;
int used = 0, total = 0;
int ig_used = 0;
int i;
unsigned long long user, nice, system, idle, iowait, irq, softirq;
unsigned long long used, total;
static unsigned long long pre_used = 0, pre_total = 0;
int result;
FILE *fp;
if (!(fp = fopen("/proc/stat", "r"))) {
perror("can't open /proc/stat");
exit(1);
}
fscanf(fp, "%*s %d %d %d %d", &cpu, &nice, &system, &idle);
#ifdef USE_SMP
if (opts->cpu_number >= 0) {
char cpu_name[20];
if (opts->cpu_number > NR_CPUS - 1) {
fprintf (stderr, "MAX CPU number that can be running in SMP is %d\n", NR_CPUS - 1);
exit(1);
FILE *fp;
if (!(fp = fopen("/proc/stat", "r"))) {
perror("fopen");
exit(1);
}
for (i = 0; i <= opts->cpu_number; i++) {
fscanf(fp, "%s %d %d %d %d", cpu_name, &cpu, &nice, &system, &idle);
if (strncmp(cpu_name, "cpu", 3)){
fprintf (stderr, "can't find cpu%d!\n", opts->cpu_number);
exit (1);
}
}
}
#endif /* USE_SMP */
fclose(fp);
used = cpu + system;
if (!opts->ignore_nice)
used += nice;
total = cpu + nice + system + idle;
if (opts->cpu_number == -1) {
if (is_linux26)
fscanf(fp, "%*s %llu %llu %llu %llu %llu %llu %llu",
&user, &nice, &system, &idle, &iowait,
&irq, &softirq);
else
fscanf(fp, "%*s %llu %llu %llu %llu",
&user, &nice, &system, &idle);
} else {
char cpu_name[20];
int i;
/* get CPU usage of processes which specified by name with '-p' option */
if (opts->ignore_procs) {
pids = 0;
if (!(pid_list = malloc(sizeof(pid_t)))) {
perror("malloc");
exit(1);
}
set_pidlist_from_namelist(opts->ignore_procs, opts->ignore_proc_list);
for (i = 0; i < pids; i++)
ig_used += get_cpuusage_bypid(pid_list[i]);
free(pid_list);
}
for (i = 0; i <= opts->cpu_number; i++)
skip_line(fp);
/* calc CPU usage */
if ((pre_total == 0) || !(total - pre_total > 0)) {
usage = 0;
} else if (ig_used - pre_ig_used > 0) {
usage = (100 * (double)(used - pre_used - ig_used + pre_ig_used)) /
(double)(total - pre_total);
} else {
usage = (100 * (double)(used - pre_used)) / (double)(total - pre_total);
}
if (is_linux26)
fscanf(fp, "%s %llu %llu %llu %llu %llu %llu %llu",
cpu_name, &user, &nice, &system, &idle, &iowait,
&irq, &softirq);
else
fscanf(fp, "%s %llu %llu %llu %llu",
cpu_name, &user, &nice, &system,
&idle);
/* save current values for next calculation */
pre_ig_used = ig_used;
pre_used = used;
pre_total = total;
return usage;
}
/* set pid list table from command names */
static void
set_pidlist_from_namelist(int names, char **name_list)
{
DIR *dir;
struct dirent *de;
FILE *fp;
char path[PATH_MAX + 1];
char comm[COMM_LEN];
pid_t pid;
int i;
if (!(dir = opendir("/proc"))) {
perror("can't open /proc");
exit(1);
}
/* search specified process from all processes */
chdir("/proc");
while ((de = readdir(dir)) != NULL) {
if ((de->d_name[0] != '.') &&
((de->d_name[0] >= '0') && (de->d_name[0] <= '9'))) {
pid = (pid_t) atoi(de->d_name);
sprintf(path, "%d/stat", pid);
if ((fp = fopen(path, "r")) != NULL) {
fscanf(fp, "%*d (%[^)]", comm);
for (i = 0; i < names; i++) {
if (strcmp(comm, name_list[i]) == 0) {
/* add process id to list */
pids++;
if (!(pid_list=realloc(pid_list, pids*sizeof(pid_t)))){
perror("realloc() failed");
exit(1);
}
pid_list[pids - 1] = pid;
}
if (cpu_name[3] != '0' + opts->cpu_number) {
fprintf(stderr, "Could not find cpu%d.\n",
opts->cpu_number);
exit(1);
}
fclose(fp);
}
}
}
closedir(dir);
}
static int
get_cpuusage_bypid(pid_t pid)
{
FILE *fp;
char path[PATH_MAX];
int utime = 0, stime = 0;
int ret = 0;
sprintf(path, "/proc/%d/stat", pid);
if ((fp = fopen(path, "r")) != NULL) {
fscanf(fp, "%*d %*s %*s %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %d %d ",
&utime, &stime);
fclose(fp);
}
ret = utime + stime;
return ret;
used = user + system;
if (!opts->ignore_nice)
used += nice;
total = user + nice + system + idle;
if (is_linux26)
total += iowait + irq + softirq;
result = (100 * (double)(used - pre_used)) / (double)(total - pre_total);
pre_total = total;
pre_used = used;
return result;
}

View file

@ -1,10 +1,13 @@
/* $Id: cpu_netbsd.c,v 1.3 2003-10-13 04:34:02 sch Exp $ */
/*
* cpu_netbsd - module to get cpu usage, for NetBSD
* cpu_netbsd - module to get cpu usage, for NetBSD
*
* This code is based on cpu_openbsd.c
*
* Copyright (c) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp>
* Copyright (c) 2002 Thomas Runge <coto@core.de>
* Copyright (c) 2002 Thomas Runge <coto@core.de>
* Copyright (C) 2003 Nedko Arnaudov <nedko@users.sourceforge.net>
*
* Licensed under the GPL
*/
@ -46,12 +49,11 @@ cpu_get_usage(cpu_options *opts)
if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
return 0;
if (opts->ignore_nice) cpu_time[CP_NICE] = 0;
/* calculate usage */
used = cpu_time[CP_USER] + cpu_time[CP_SYS] +
cpu_time[CP_NICE] + cpu_time[CP_INTR];
total = used + cpu_time[CP_IDLE];
total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
cpu_time[CP_NICE] + cpu_time[CP_IDLE];
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
(opts->ignore_nice ? 0 : cpu_time[CP_NICE]);
if ((pre_total == 0) || !(total - pre_total > 0)) {
result = 0;
} else {

View file

@ -1,7 +1,10 @@
/* $Id: cpu_openbsd.c,v 1.3 2003-10-13 04:34:02 sch Exp $ */
/*
* cpu_openbsd - module to get cpu usage, for OpenBSD
*
* Copyright (C) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp>
* Copyright (C) 2003 Nedko Arnaudov <nedko@users.sourceforge.net>
*
* Licensed under the GPL
*/
@ -43,18 +46,14 @@ cpu_get_usage(cpu_options *opts)
return 0;
/* calc usage */
used = cpu_time[CP_USER] + cpu_time[CP_SYS];
if (!opts->ignore_nice) {
used += cpu_time[CP_NICE];
}
total = used + cpu_time[CP_IDLE];
if (pre_total == 0) {
total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
cpu_time[CP_NICE] + cpu_time[CP_IDLE];
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
(opts->ignore_nice ? 0 : cpu_time[CP_NICE]);
if ((pre_total == 0) || !(total - pre_total > 0)) {
result = 0;
} else if ((total - pre_total) > 0) {
result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
} else {
result = 0;
result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
}
/* save used/total for next calculation */

View file

@ -1,3 +1,5 @@
/* $Id: cpu_solaris.c,v 1.1.1.1 2002-10-14 09:31:17 sch Exp $ */
/*
* cpu_solaric.c - module to get cpu usage, for Solaris
*

View file

@ -1,3 +1,5 @@
/* $Id: main.c,v 1.6 2006-01-28 10:40:09 sch Exp $ */
/*
* WMCPULoad - A dockapp to monitor CPU usage
* Copyright (C) 2001,2002 Seiichi SATO <ssato@sh.rim.or.jp>
@ -14,7 +16,7 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
@ -35,11 +37,9 @@
typedef enum { LIGHTON, LIGHTOFF } light;
Pixmap pixmap;
Pixmap backdrop_on;
Pixmap backdrop_off;
Pixmap parts;
Pixmap pix_chartbuf;
Pixmap mask;
static char *display_name = "";
static char *title = NULL;
@ -53,10 +53,12 @@ static int hindex = 0;
/* prototypes */
static void update(void);
static void redraw(void);
static void switch_light(void);
static void draw_digit(int per);
static void parse_arguments(int argc, char **argv);
static void print_help(char *prog);
Window dockapp_win(void);
#if USE_SMP
static void draw_cpunumber(void);
#endif
@ -71,14 +73,13 @@ main(int argc, char **argv)
/* Parse Command-Line */
cpu_opts.ignore_nice = False;
cpu_opts.cpu_number = CPUNUM_NONE;
cpu_opts.ignore_procs = 0;
parse_arguments(argc, argv);
/* Initialize Application */
cpu_init();
dockapp_open_window(display_name, title == NULL ? PACKAGE : title,
SIZE, SIZE, argc, argv);
dockapp_set_eventmask(ButtonPressMask);
dockapp_set_eventmask(ButtonPressMask | ExposureMask);
if (light_color) {
colors[0].pixel = dockapp_getcolor_pixel(light_color);
@ -87,9 +88,8 @@ main(int argc, char **argv)
}
/* change raw xpm data to pixmap */
if (dockapp_stat == WINDOWED_WITH_PANEL) {
if (dockapp_stat == WINDOWED_WITH_PANEL)
backlight_on_xpm[1] = backlight_off_xpm[1] = WINDOWED_BG;
}
dockapp_xpm2pixmap(backlight_on_xpm, &backdrop_on, &mask, colors, ncolor);
dockapp_xpm2pixmap(backlight_off_xpm, &backdrop_off, NULL, NULL, 0);
dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor);
@ -98,17 +98,13 @@ main(int argc, char **argv)
dockapp_setshape(mask, 0, 0);
}
if (mask) XFreePixmap(display, mask);
/* pixmap : draw area */
pixmap = dockapp_XCreatePixmap(SIZE, SIZE);
pix_chartbuf = dockapp_XCreatePixmap(SIZE, SIZE);
/* Initialize pixmap */
if (backlight == LIGHTON) {
dockapp_copyarea(backdrop_on, pixmap, 0, 0, SIZE, SIZE, 0, 0);
dockapp_set_background(backdrop_on);
} else {
dockapp_copyarea(backdrop_off, pixmap, 0, 0, SIZE, SIZE, 0, 0);
dockapp_set_background(backdrop_off);
}
dockapp_set_background(pixmap);
dockapp_show();
/* Main loop */
@ -118,6 +114,10 @@ main(int argc, char **argv)
switch(event.type) {
case ButtonPress:
switch_light();
redraw();
break;
case Expose:
redraw();
break;
default: /* make gcc happy */
break;
@ -137,10 +137,19 @@ update(void)
{
int usage;
int x, h;
Pixmap backdrop;
static light pre_backlight;
static Bool in_alarm_mode = False;
if (backlight == LIGHTON) {
backdrop = backdrop_on;
x = 2;
} else {
backdrop = backdrop_off;
x = 0;
}
/* get current cpu usage in percent */
usage = cpu_get_usage(&cpu_opts);
hindex++;
@ -157,6 +166,7 @@ update(void)
}
if (backlight == LIGHTOFF) {
switch_light();
redraw();
return;
}
} else {
@ -164,22 +174,18 @@ update(void)
in_alarm_mode = False;
if (backlight != pre_backlight) {
switch_light();
redraw();
return;
}
}
}
/* save current chart */
dockapp_copyarea(pixmap, pix_chartbuf, 9, 33, 44, 21, 0, 0);
/* slide past chart */
dockapp_copyarea(dockapp_win(), dockapp_win(), 9, 33, 44, 21, 6, 33);
dockapp_copy2window(backdrop, 51, 33, 2, 21, 51, 33);
/* all clear */
if (backlight == LIGHTON) {
dockapp_copyarea(backdrop_on, pixmap, 0, 0, 58, 58, 0, 0);
x = 2;
} else {
dockapp_copyarea(backdrop_off, pixmap, 0, 0, 58, 58, 0, 0);
x = 0;
}
/* clear digit */
dockapp_copy2window(backdrop, 5, 7, 34, 20, 5, 7);
/* draw digit */
draw_digit(usage);
@ -190,35 +196,41 @@ update(void)
draw_cpunumber();
#endif
/* draw chart */
/* draw current chart */
h = (21 * usage) / 100;
dockapp_copyarea(pix_chartbuf, pixmap, 0, 0, 44, 21, 6, 33);
dockapp_copyarea(parts, pixmap,100+x, 21-h, 2, h, 51, 54-h);
/* show */
dockapp_copy2window(pixmap);
dockapp_copy2window(parts, 100+x, 21-h, 2, h, 51, 54-h);
}
/* called when mouse button pressed */
static void
switch_light(void)
{
int h, i, j = hindex;
int x = 0;
switch (backlight) {
case LIGHTOFF:
backlight = LIGHTON;
dockapp_copyarea(backdrop_on, pixmap, 0, 0, 58, 58, 0, 0);
x = 2;
break;
case LIGHTON:
backlight = LIGHTOFF;
dockapp_copyarea(backdrop_off, pixmap, 0, 0, 58, 58, 0, 0);
x = 0;
break;
}
}
static void
redraw(void)
{
int h, i, j = hindex;
int x = 0;
Pixmap backdrop;
if (backlight == LIGHTON) {
backdrop = backdrop_on;
x = 2;
} else {
backdrop = backdrop_off;
x = 0;
}
dockapp_copy2window(backdrop, 0, 0, 58, 58, 0, 0);
/* redraw digit */
draw_digit(history[hindex]);
@ -232,13 +244,10 @@ switch_light(void)
/* redraw chart */
for (i = 0; i < MAX_HISTORY; i++) {
h = (21 * history[j]) / 100;
dockapp_copyarea(parts, pixmap, 100+x, 21-h, 2, h, 51-3*i, 54-h);
dockapp_copy2window(parts, 100+x, 21-h, 2, h, 51-3*i, 54-h);
j--;
if (j < 0) j = MAX_HISTORY - 1;
}
/* show */
dockapp_copy2window(pixmap);
}
static void
@ -259,15 +268,16 @@ draw_digit(int per)
}
/* draw digit */
dockapp_copyarea(parts, pixmap, v1 * 10, y, 10, 20, 29, 7);
dockapp_copy2window(parts, v1 * 10, y, 10, 20, 29, 7);
if (v10 != 0) {
dockapp_copyarea(parts, pixmap, v10 * 10, y, 10, 20, 17, 7);
dockapp_copy2window(parts, v10 * 10, y, 10, 20, 17, 7);
}
if (v100 == 1) {
dockapp_copyarea(parts, pixmap, 10, y, 10, 20, 5, 7);
dockapp_copyarea(parts, pixmap, 0, y, 10, 20, 17, 7);
dockapp_copyarea(parts, pixmap, 0, y, 10, 20, 29, 7);
dockapp_copy2window(parts, 10, y, 10, 20, 5, 7);
dockapp_copy2window(parts, 0, y, 10, 20, 17, 7);
dockapp_copy2window(parts, 0, y, 10, 20, 29, 7);
}
}
@ -275,20 +285,17 @@ draw_digit(int per)
static void
draw_cpunumber(void)
{
int x_offset = 0;
int v10 = 0, v1 = 0;
int x, v1 = 0, v2 = 0;
v10 = cpu_opts.cpu_number / 10;
v1 = cpu_opts.cpu_number - v10 * 10;
v2 = cpu_opts.cpu_number / 10;
v1 = cpu_opts.cpu_number - v2 * 10;
if (backlight == LIGHTON) {
x_offset = 50;
}
x = backlight == LIGHTON ? 50 : 0;
if (v10) {
dockapp_copyarea(parts, pixmap, x_offset + v10 * 5, 40, 5, 9, 44, 10);
}
dockapp_copyarea(parts, pixmap, x_offset + v1 * 5, 40, 5, 9, 50, 10);
if (v2)
dockapp_copy2window(parts, x + v2 * 5, 40, 5, 9, 44, 10);
dockapp_copy2window(parts, x + v1 * 5, 40, 5, 9, 50, 10);
}
#endif
@ -362,33 +369,6 @@ parse_arguments(int argc, char **argv)
i++;
}
#ifdef IGNORE_PROC
else if (!strcmp(argv[i], "--ignore-proc") || !strcmp(argv[i], "-p")) {
if (argc == i + 1)
fprintf(stderr, "%s: error parsing argument for option %s\n",
argv[0], argv[i]), exit(1);
if (argv[i + 1][0] == '-')
fprintf(stderr, "%s: error parsing argument for option %s\n",
argv[0], argv[i]), exit(1);
while (i + 1 < argc) {
if (!(argv[i + 1][0] == '-')) {
if (strlen(argv[i + 1]) >= COMM_LEN)
fprintf(stderr, "%s: command name %s is longer than 15 characters\n",
argv[0], argv[i + 1]), exit(1);
if (cpu_opts.ignore_procs == MAX_PROC)
fprintf(stderr, "%s: maximum number of command names is %d\n",
argv[0], MAX_PROC), exit(1);
cpu_opts.ignore_proc_list[cpu_opts.ignore_procs] = argv[i + 1];
cpu_opts.ignore_procs++;
} else {
break;
}
i++;
}
}
#endif /* IGNORE_PROC */
#ifdef USE_SMP
else if (!strcmp(argv[i], "--cpu") || !strcmp(argv[i], "-c")) {
int integer;
@ -412,13 +392,6 @@ parse_arguments(int argc, char **argv)
print_help(argv[0]), exit(1);
}
}
#if defined(USE_SMP) && defined(IGNORE_PROC)
if (cpu_opts.cpu_number != CPUNUM_NONE && cpu_opts.ignore_procs) {
fprintf(stderr, "You can't use '-c, --cpu' option with '-p, --ignore_procs' option");
exit (1);
}
#endif
}
static void
@ -429,23 +402,29 @@ print_help(char *prog)
printf(" -d, --display <string> display to use\n");
printf(" -t, --title <string> application title name\n");
printf(" -bl, --backlight turn on back-light\n");
printf(" -lc, --light-color <string> back-light color(rgb:6E/C6/3B is default)\n");
printf(" -i, --interval <number> number of secs between updates (1 is default)\n");
printf(" -lc, --light-color <string> "
"back-light color(rgb:6E/C6/3B is default)\n");
printf(" -i, --interval <number> "
"number of secs between updates (1 is default)\n");
#ifdef USE_SMP
printf(" -c, --cpu <number> CPU number (0, 1, ... )\n");
printf(" -c, --cpu <number> "
"which CPU is monitored (0, 1, ... )\n");
#endif
#ifdef IGNORE_NICE
printf(" -n, --ignore-nice ignore a nice value\n");
#endif
#ifdef IGNORE_PROC
printf(" -p, --ignore-proc <name> .. ignore all processes specified by command name\n");
#endif
printf(" -h, --help show this help text and exit\n");
printf(" -v, --version show program version and exit\n");
printf(" -w, --windowed run the application in windowed mode\n");
printf(" -wp, --windowed-withpanel run the application in windowed mode\n");
printf(" -w, --windowed "
"run the application in windowed mode\n");
printf(" -wp, --windowed-withpanel "
"run the application in windowed mode\n");
printf(" with background panel\n");
printf(" -bw, --broken-wm activate broken window manager fix\n");
printf(" -a, --alarm <percentage> activate alarm mode. <percentage> is threshold\n");
printf(" of percentage from 0 to 100.(90 is default)\n");
printf(" -bw, --broken-wm "
"activate broken window manager fix\n");
printf(" -a, --alarm <percentage> "
"activate alarm mode. <percentage> is threshold\n");
printf(" "
"of percentage from 0 to 100.(90 is default)\n");
}
/* ex:set sw=4 softtabstop=4: */