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: Main Author:
Seiichi SATO <ssato@sh.rim.or.jp> Seiichi SATO <ssato@sh.rim.or.jp>
Solaris port: Solaris port:
Jonathan Lang <lang@synopsys.com> Jonathan Lang <lang@synopsys.com>
Writting manpage: Man-page:
Gordon Fraser <gordon@debian.org> Gordon Fraser <gordon@debian.org>
NetBSD port: NetBSD port:
@ -12,3 +14,9 @@ Thomas Runge <coto@core.de>
BSDi port: BSDi port:
Nicolas Belan <belan@matranet.com> 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 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public 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 General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by 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. your programs, too.
When we speak of free software, we are referring to freedom, not 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 The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 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 License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on does not normally print such an announcement, your work based on
the Program is not required to print an announcement.) the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program, identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in 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 access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not distribution of the source code, even though third parties are not
compelled to copy the source along with the object code. compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program 4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is 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 This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License. be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in 8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License 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 preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. 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 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 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 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest 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 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License
with this program; if not, write to the Free Software Foundation, Inc., along with this program; if not, write to the Free Software
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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. 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 If the program is interactive, make it output a short notice like this
when it starts in an interactive mode: 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'. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. 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 This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the 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. 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 2002 Jul 14
* version 1.0.0 released * version 1.0.0 released
@ -11,13 +65,13 @@
* src/Makefile.am: added missing @DFLAGS@ * src/Makefile.am: added missing @DFLAGS@
2002 May 17 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 2002 April 09
* dockapp.c, dockapp.h: moved to libdockapp/dockapp.[ch] * dockapp.c, dockapp.h: moved to libdockapp/dockapp.[ch]
* libdockapp/{COPYING,AUTHORS}: added (taken from libdockapp-0.4.0) * libdockapp/{COPYING,AUTHORS}: added (taken from libdockapp-0.4.0)
* configure.ac: removed '-L/usr/local/lib' '-I/usr/local/include' from * 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 * README: added 'for GNOME users' section
2002 April 05 2002 April 05
@ -28,7 +82,7 @@
* dockapp.c: removed background panel from windowed mode. * dockapp.c: removed background panel from windowed mode.
* dockapp.c: added '-wp, --windowed-withpanel' option. * dockapp.c: added '-wp, --windowed-withpanel' option.
* main.c: added '-t, --title' option to specify title name * 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 * wmcpuload.1: updated
* cpu_netbsd.c: added 'CP_INTR' parameter * cpu_netbsd.c: added 'CP_INTR' parameter

View file

@ -1,12 +1,13 @@
$Id: INSTALL,v 1.2 2003-04-06 09:12:41 sch Exp $
Supported Platforms: Supported Platforms:
==================== ====================
(ie: I've heard someone has compiled it on...) (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) - GNU/Linux Mandrake 7.2, 8.0, 8.1, 8.2 (x86, ppc)
- Debian GNU/Linux 2.2 potato (x86) - 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) (x86, alpha, arm, hppa, ia64, m68k, mips, ppc, s390, sparc)
- GNU/Linux SuSE 7.0, 7.1 (x86) - GNU/Linux SuSE 7.0, 7.1 (x86)
- GNU/Linux Gentoo 1.0, 1.0a (x86, powerpc) - GNU/Linux Gentoo 1.0, 1.0a (x86, powerpc)
@ -14,11 +15,13 @@ Supported Platforms:
- FreeBSD 4-STABLE (x86, alpha) - FreeBSD 4-STABLE (x86, alpha)
- FreeBSD 5-CURRENT (x86, alpha) - FreeBSD 5-CURRENT (x86, alpha)
- OpenBSD 2.9 (x86) - 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 - BSDi 4.1
- Solaris 7, 8 - Solaris 7, 8
- Cygwin 1.3.3 / Windows 98, Me - Cygwin 1.3.3 / Windows 98, Me
- Cygwin 1.3.10 / Windows 98, Me, 2000 - 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. 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 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: 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 WMCPULoad - A dockapp to monitor CPU usage
General Information 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 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. 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 Installation
============ ============
@ -31,7 +34,7 @@ $ wmcpuload [OPTIONS]
-bl, --backlight turn on back-light -bl, --backlight turn on back-light
-lc, --light-color <color> back-light color (rgb:6E/C6/3B is default) -lc, --light-color <color> back-light color (rgb:6E/C6/3B is default)
-i, --interval <number> number of secs between updates (1 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 -n, --ignore-nice ignore a nice value
-p, --ignore-proc <name><...> ignore all processes specified by command name -p, --ignore-proc <name><...> ignore all processes specified by command name
-h, --help show this help text and exit -h, --help show this help text and exit
@ -46,12 +49,12 @@ $ wmcpuload [OPTIONS]
NOTES: NOTES:
- '-n, --ignore-nice' option is activated under GNU/Linux / {Free,Open,Net}BSD. - '-n, --ignore-nice' option is activated under GNU/Linux / {Free,Open,Net}BSD.
- '-p, --ignore-proc' option is activated under GNU/Linux. - '-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 For AfterStep users
=================== ===================
Add below entry to your Wharf Add this line to your ~/GNUstep/Library/AfterStep/wharf:
*Wharf wmcpuload - Swallow "wmcpuload" wmcpuload -w & *Wharf wmcpuload - Swallow "wmcpuload" wmcpuload -w &
@ -66,8 +69,7 @@ open 'Create swallow Applet' dialog and enter the values as below.
3. width: 62 3. width: 62
4. height: 62 4. height: 62
NOTE: You can't run swallowed application with sawfish 1.0.1. This problem has NOTE: GNOME2 does not support the swallowed application.
fixed in current cvs.
For Enlightenment users For Enlightenment users
@ -77,7 +79,7 @@ Use '-bw, --broken-wm' option.
For Golem users 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 "item" "dock" {
param "cmd" "exec wmcpuload"; param "cmd" "exec wmcpuload";
@ -91,7 +93,7 @@ Frequently Asked Questions
Q) Which window managers do support dockapps? Q) Which window managers do support dockapps?
A) - Window Maker http://www.windowmaker.org/ A) - Window Maker http://www.windowmaker.org/
- AfterStep http://www.afterstep.org/ - AfterStep http://www.afterstep.org/
- Blackbox http://blackbox.alug.org/ - Blackbox http://blackboxwm.sourceforge.net/
- Enlightenment http://www.enlightenment.org/ - Enlightenment http://www.enlightenment.org/
- Fluxbox http://fluxbox.sourceforge.net/ - Fluxbox http://fluxbox.sourceforge.net/
- Waimea http://waimea.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) * 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 * 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. dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52) AC_PREREQ(2.52)
dnl AC_INIT(src/main.c) dnl AC_INIT(src/main.c)
dnl AM_INIT_AUTOMAKE(wmcpuload, 0.9.0) 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_HOST
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
@ -89,15 +91,13 @@ dnl Determine OS
dnl ============ dnl ============
ignore_nice=no ignore_nice=no
ignore_proc=no use_smp=no
case ${target_os} in case ${target_os} in
linux*) linux*)
OS=linux OS=linux
ignore_nice=yes ignore_nice=yes
ignore_proc=yes use_smp=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"])
;; ;;
freebsd*) freebsd*)
OS=freebsd OS=freebsd
@ -124,6 +124,13 @@ solaris*)
cygwin*) cygwin*)
OS=cygwin OS=cygwin
;; ;;
irix*)
OS=irix
use_smp=yes
;;
darwin*)
OS=darwin
;;
*) *)
echo "" echo ""
echo "Sorry, ${target_os} is not supported yet" echo "Sorry, ${target_os} is not supported yet"
@ -139,8 +146,8 @@ AC_SUBST(LIBS)
if test "$ignore_nice" = yes; then if test "$ignore_nice" = yes; then
AC_DEFINE(IGNORE_NICE, 1, [use '--ignore-nice' option]) AC_DEFINE(IGNORE_NICE, 1, [use '--ignore-nice' option])
fi fi
if test "$ignore_proc" = yes; then if test "$use_smp" = yes; then
AC_DEFINE(IGNORE_PROC, 1, [use '--ignore-process' option]) AC_DEFINE(USE_SMP, 1, [use SMP support])
fi 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 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 *** wmcpuload.spec
author: 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 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 -*- .\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@ -57,7 +58,7 @@ back-light color (rgb:6E/C6/3B is default)
.B \-i, \-\-interval <number> .B \-i, \-\-interval <number>
number of secs between updates (1 is default) number of secs between updates (1 is default)
.TP .TP
.B \-c, \-\-cpu <number> .B \-c, \-\-cpu <number> (GNU/Linux / IRIX)
CPU number to monitor (Counting starts with 0). CPU number to monitor (Counting starts with 0).
.TP .TP
.B \-n, \-\-ignore\-nice (GNU/Linux / FreeBSD / OpenBSD / NetBSD) .B \-n, \-\-ignore\-nice (GNU/Linux / FreeBSD / OpenBSD / NetBSD)
@ -80,9 +81,6 @@ activate broken window manager fix
.TP .TP
.B \-a, \-\-alarm <percentage> .B \-a, \-\-alarm <percentage>
activate alarm mode. <percentage> is threshold of percentage from 0 to 100.(90 is default) 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 .SH AUTHOR
WMCPULoad was written by Seiichi SATO <ssato@sh.rim.or.jp>. 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 = \ EXTRA_DIST = \
wmcpuload-16x16.xpm \ wmcpuload-16x16.xpm \
wmcpuload-32x32.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 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 * 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, dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src, int w, int h,
int x_dist, int y_dist) 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); XCopyArea(display, src, dist, gc, x_src, y_src, w, h, x_dist, y_dist);
} }
void 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) { Window win;
XCopyArea(display, src, window, gc, 0, 0, width, height, offset_w,
offset_h); win = dockapp_isbrokenwm ? window : icon_window;
} else {
XCopyArea(display, src, icon_window, gc, 0, 0, width, height, offset_w, XCopyArea(display, src, win, gc, x_src, y_src, w, h, offset_w + x_dist,
offset_h); offset_h + y_dist);
}
} }
Window
dockapp_win(void)
{
return dockapp_isbrokenwm ? window : icon_window;
}
Bool Bool
dockapp_nextevent_or_timeout(XEvent *event, unsigned long miliseconds) 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; 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 * 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_setshape(Pixmap mask, int x_ofs, int y_ofs);
void dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src, void dockapp_copyarea(Pixmap src, Pixmap dist, int x_src, int y_src,
int w, int h, int x_dist, int y_dist); 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); 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 bin_PROGRAMS = wmcpuload
wmcpuload_SOURCES = \ wmcpuload_SOURCES = \
@ -15,7 +17,9 @@ EXTRA_wmcpuload_SOURCES = \
cpu_netbsd.c \ cpu_netbsd.c \
cpu_bsdi.c \ cpu_bsdi.c \
cpu_solaris.c \ cpu_solaris.c \
cpu_cygwin.c cpu_cygwin.c \
cpu_irix.c \
cpu_darwin.c
wmcpuload_DEPENDENCIES = ../libdockapp/dockapp.o 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 * cpu.h - header file of the module to get cpu usage
* *
@ -13,13 +15,11 @@
#define COMM_LEN 16 #define COMM_LEN 16
#endif #endif
#define MAX_PROC 5 #define MAX_PROC 5
#define MAX_CPU 99
typedef struct _cpu_options { typedef struct _cpu_options {
int ignore_nice; int ignore_nice;
int cpu_number; int cpu_number;
char *ignore_proc_list[MAX_PROC];
int ignore_procs;
} cpu_options; } cpu_options;
void cpu_init(void); 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 * 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 * 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", if (RegOpenKeyEx(HKEY_DYN_DATA, "PerfStats\\StatData",
0, KEY_READ, &hkeyr) != ERROR_SUCCESS) { 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; return 0;
} }
@ -150,14 +152,14 @@ cpu_get_usage_NT(cpu_options *opts)
SYSTEM_PERFORMANCE_INFORMATION spi; SYSTEM_PERFORMANCE_INFORMATION spi;
if ((h_ntdll = LoadLibraryEx("NTDLL.DLL", NULL, 0)) == NULL) { 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); exit (1);
} }
NtQuerySystemInformation = GetProcAddress(h_ntdll, NtQuerySystemInformation = GetProcAddress(h_ntdll,
"NtQuerySystemInformation"); "NtQuerySystemInformation");
if (!NtQuerySystemInformation) { if (!NtQuerySystemInformation) {
fprintf(stderr, "%s: can't find NtQuerySystemInformation()\n", PACKAGE); fprintf(stderr, "%s: could not find NtQuerySystemInformation()\n", PACKAGE);
FreeLibrary(h_ntdll); FreeLibrary(h_ntdll);
return 0; 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 * 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 * Licensed under the GPL
*/ */
@ -18,7 +20,14 @@
#include <kvm.h> #include <kvm.h>
#include <fcntl.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 kvm_t *kd = NULL;
static struct nlist nlst[] = { {"_cp_time"}, {0} }; static struct nlist nlst[] = { {"_cp_time"}, {0} };
@ -63,20 +72,18 @@ cpu_get_usage(cpu_options *opts)
sizeof(cpu_time)) sizeof(cpu_time))
return 0; return 0;
used = cpu_time[CP_USER] + cpu_time[CP_SYS]; /* calculate usage */
if (!opts->ignore_nice) total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
used += cpu_time[CP_NICE]; cpu_time[CP_NICE] + cpu_time[CP_IDLE];
total = used + 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) { if ((pre_total == 0) || !(total - pre_total > 0)) {
result = 0; result = 0;
} else if ((total - pre_total) > 0) {
result = (100 * (double) (used - pre_used)) / (double) (total -
pre_total);
} else { } else {
result = 0; result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
} }
/* save used/total for next calculation */
pre_used = used; pre_used = used;
pre_total = total; 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 #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
@ -21,156 +37,97 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <linux/limits.h> #include <linux/limits.h>
#ifdef USE_SMP static int is_linux26;
#include <linux/threads.h>
#endif
static void set_pidlist_from_namelist(int names, char **name_list); static void
static int get_cpuusage_bypid(pid_t pid); skip_line(FILE *fp)
static int *pid_list;
static int pids;
void cpu_init(void)
{ {
/* You don't need initialization under GNU/Linux */ int c;
return;
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 */ /* returns current cpu usage in percent */
int int
cpu_get_usage(cpu_options *opts) cpu_get_usage(cpu_options * opts)
{ {
static int pre_used, pre_total; unsigned long long user, nice, system, idle, iowait, irq, softirq;
static int pre_ig_used; unsigned long long used, total;
int usage; static unsigned long long pre_used = 0, pre_total = 0;
int cpu, nice, system, idle; int result;
int used = 0, total = 0;
int ig_used = 0;
int i;
FILE *fp; FILE *fp;
if (!(fp = fopen("/proc/stat", "r"))) { if (!(fp = fopen("/proc/stat", "r"))) {
perror("can't open /proc/stat"); perror("fopen");
exit(1); 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);
} }
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); if (opts->cpu_number == -1) {
used = cpu + system; if (is_linux26)
if (!opts->ignore_nice) fscanf(fp, "%*s %llu %llu %llu %llu %llu %llu %llu",
used += nice; &user, &nice, &system, &idle, &iowait,
total = cpu + nice + system + idle; &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 */ for (i = 0; i <= opts->cpu_number; i++)
if (opts->ignore_procs) { skip_line(fp);
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);
}
/* calc CPU usage */ if (is_linux26)
if ((pre_total == 0) || !(total - pre_total > 0)) { fscanf(fp, "%s %llu %llu %llu %llu %llu %llu %llu",
usage = 0; cpu_name, &user, &nice, &system, &idle, &iowait,
} else if (ig_used - pre_ig_used > 0) { &irq, &softirq);
usage = (100 * (double)(used - pre_used - ig_used + pre_ig_used)) / else
(double)(total - pre_total); fscanf(fp, "%s %llu %llu %llu %llu",
} else { cpu_name, &user, &nice, &system,
usage = (100 * (double)(used - pre_used)) / (double)(total - pre_total); &idle);
}
/* save current values for next calculation */ if (cpu_name[3] != '0' + opts->cpu_number) {
pre_ig_used = ig_used; fprintf(stderr, "Could not find cpu%d.\n",
pre_used = used; opts->cpu_number);
pre_total = total; exit(1);
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;
}
} }
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); fclose(fp);
}
ret = utime + stime; used = user + system;
return ret; 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 * This code is based on cpu_openbsd.c
* *
* Copyright (c) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp> * 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 * Licensed under the GPL
*/ */
@ -46,12 +49,11 @@ cpu_get_usage(cpu_options *opts)
if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0) if (sysctl(mib, 2, &cpu_time, &size, NULL, 0) < 0)
return 0; return 0;
if (opts->ignore_nice) cpu_time[CP_NICE] = 0;
/* calculate usage */ /* calculate usage */
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
cpu_time[CP_NICE] + cpu_time[CP_INTR]; cpu_time[CP_NICE] + cpu_time[CP_IDLE];
total = used + 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)) { if ((pre_total == 0) || !(total - pre_total > 0)) {
result = 0; result = 0;
} else { } 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 * cpu_openbsd - module to get cpu usage, for OpenBSD
* *
* Copyright (C) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp> * Copyright (C) 2001, 2002 Seiichi SATO <ssato@sh.rim.or.jp>
* Copyright (C) 2003 Nedko Arnaudov <nedko@users.sourceforge.net>
* *
* Licensed under the GPL * Licensed under the GPL
*/ */
@ -43,18 +46,14 @@ cpu_get_usage(cpu_options *opts)
return 0; return 0;
/* calc usage */ /* calc usage */
used = cpu_time[CP_USER] + cpu_time[CP_SYS]; total = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
if (!opts->ignore_nice) { cpu_time[CP_NICE] + cpu_time[CP_IDLE];
used += cpu_time[CP_NICE]; used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_INTR] +
} (opts->ignore_nice ? 0 : cpu_time[CP_NICE]);
total = used + cpu_time[CP_IDLE]; if ((pre_total == 0) || !(total - pre_total > 0)) {
if (pre_total == 0) {
result = 0; result = 0;
} else if ((total - pre_total) > 0) {
result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
} else { } else {
result = 0; result = 100 * (double)(used - pre_used) / (double)(total - pre_total);
} }
/* save used/total for next calculation */ /* 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 * 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 * WMCPULoad - A dockapp to monitor CPU usage
* Copyright (C) 2001,2002 Seiichi SATO <ssato@sh.rim.or.jp> * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * 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; typedef enum { LIGHTON, LIGHTOFF } light;
Pixmap pixmap;
Pixmap backdrop_on; Pixmap backdrop_on;
Pixmap backdrop_off; Pixmap backdrop_off;
Pixmap parts; Pixmap parts;
Pixmap pix_chartbuf;
Pixmap mask; Pixmap mask;
static char *display_name = ""; static char *display_name = "";
static char *title = NULL; static char *title = NULL;
@ -53,10 +53,12 @@ static int hindex = 0;
/* prototypes */ /* prototypes */
static void update(void); static void update(void);
static void redraw(void);
static void switch_light(void); static void switch_light(void);
static void draw_digit(int per); static void draw_digit(int per);
static void parse_arguments(int argc, char **argv); static void parse_arguments(int argc, char **argv);
static void print_help(char *prog); static void print_help(char *prog);
Window dockapp_win(void);
#if USE_SMP #if USE_SMP
static void draw_cpunumber(void); static void draw_cpunumber(void);
#endif #endif
@ -71,14 +73,13 @@ main(int argc, char **argv)
/* Parse Command-Line */ /* Parse Command-Line */
cpu_opts.ignore_nice = False; cpu_opts.ignore_nice = False;
cpu_opts.cpu_number = CPUNUM_NONE; cpu_opts.cpu_number = CPUNUM_NONE;
cpu_opts.ignore_procs = 0;
parse_arguments(argc, argv); parse_arguments(argc, argv);
/* Initialize Application */ /* Initialize Application */
cpu_init(); cpu_init();
dockapp_open_window(display_name, title == NULL ? PACKAGE : title, dockapp_open_window(display_name, title == NULL ? PACKAGE : title,
SIZE, SIZE, argc, argv); SIZE, SIZE, argc, argv);
dockapp_set_eventmask(ButtonPressMask); dockapp_set_eventmask(ButtonPressMask | ExposureMask);
if (light_color) { if (light_color) {
colors[0].pixel = dockapp_getcolor_pixel(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 */ /* 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; backlight_on_xpm[1] = backlight_off_xpm[1] = WINDOWED_BG;
}
dockapp_xpm2pixmap(backlight_on_xpm, &backdrop_on, &mask, colors, ncolor); dockapp_xpm2pixmap(backlight_on_xpm, &backdrop_on, &mask, colors, ncolor);
dockapp_xpm2pixmap(backlight_off_xpm, &backdrop_off, NULL, NULL, 0); dockapp_xpm2pixmap(backlight_off_xpm, &backdrop_off, NULL, NULL, 0);
dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor); dockapp_xpm2pixmap(parts_xpm, &parts, NULL, colors, ncolor);
@ -98,17 +98,13 @@ main(int argc, char **argv)
dockapp_setshape(mask, 0, 0); dockapp_setshape(mask, 0, 0);
} }
if (mask) XFreePixmap(display, mask); if (mask) XFreePixmap(display, mask);
/* pixmap : draw area */
pixmap = dockapp_XCreatePixmap(SIZE, SIZE);
pix_chartbuf = dockapp_XCreatePixmap(SIZE, SIZE);
/* Initialize pixmap */ /* Initialize pixmap */
if (backlight == LIGHTON) { if (backlight == LIGHTON) {
dockapp_copyarea(backdrop_on, pixmap, 0, 0, SIZE, SIZE, 0, 0); dockapp_set_background(backdrop_on);
} else { } else {
dockapp_copyarea(backdrop_off, pixmap, 0, 0, SIZE, SIZE, 0, 0); dockapp_set_background(backdrop_off);
} }
dockapp_set_background(pixmap);
dockapp_show(); dockapp_show();
/* Main loop */ /* Main loop */
@ -118,6 +114,10 @@ main(int argc, char **argv)
switch(event.type) { switch(event.type) {
case ButtonPress: case ButtonPress:
switch_light(); switch_light();
redraw();
break;
case Expose:
redraw();
break; break;
default: /* make gcc happy */ default: /* make gcc happy */
break; break;
@ -137,10 +137,19 @@ update(void)
{ {
int usage; int usage;
int x, h; int x, h;
Pixmap backdrop;
static light pre_backlight; static light pre_backlight;
static Bool in_alarm_mode = False; 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 */ /* get current cpu usage in percent */
usage = cpu_get_usage(&cpu_opts); usage = cpu_get_usage(&cpu_opts);
hindex++; hindex++;
@ -157,6 +166,7 @@ update(void)
} }
if (backlight == LIGHTOFF) { if (backlight == LIGHTOFF) {
switch_light(); switch_light();
redraw();
return; return;
} }
} else { } else {
@ -164,22 +174,18 @@ update(void)
in_alarm_mode = False; in_alarm_mode = False;
if (backlight != pre_backlight) { if (backlight != pre_backlight) {
switch_light(); switch_light();
redraw();
return; return;
} }
} }
} }
/* save current chart */ /* slide past chart */
dockapp_copyarea(pixmap, pix_chartbuf, 9, 33, 44, 21, 0, 0); dockapp_copyarea(dockapp_win(), dockapp_win(), 9, 33, 44, 21, 6, 33);
dockapp_copy2window(backdrop, 51, 33, 2, 21, 51, 33);
/* all clear */ /* clear digit */
if (backlight == LIGHTON) { dockapp_copy2window(backdrop, 5, 7, 34, 20, 5, 7);
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;
}
/* draw digit */ /* draw digit */
draw_digit(usage); draw_digit(usage);
@ -190,35 +196,41 @@ update(void)
draw_cpunumber(); draw_cpunumber();
#endif #endif
/* draw chart */ /* draw current chart */
h = (21 * usage) / 100; h = (21 * usage) / 100;
dockapp_copyarea(pix_chartbuf, pixmap, 0, 0, 44, 21, 6, 33); dockapp_copy2window(parts, 100+x, 21-h, 2, h, 51, 54-h);
dockapp_copyarea(parts, pixmap,100+x, 21-h, 2, h, 51, 54-h);
/* show */
dockapp_copy2window(pixmap);
} }
/* called when mouse button pressed */ /* called when mouse button pressed */
static void static void
switch_light(void) switch_light(void)
{ {
int h, i, j = hindex;
int x = 0;
switch (backlight) { switch (backlight) {
case LIGHTOFF: case LIGHTOFF:
backlight = LIGHTON; backlight = LIGHTON;
dockapp_copyarea(backdrop_on, pixmap, 0, 0, 58, 58, 0, 0);
x = 2;
break; break;
case LIGHTON: case LIGHTON:
backlight = LIGHTOFF; backlight = LIGHTOFF;
dockapp_copyarea(backdrop_off, pixmap, 0, 0, 58, 58, 0, 0);
x = 0;
break; 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 */ /* redraw digit */
draw_digit(history[hindex]); draw_digit(history[hindex]);
@ -232,13 +244,10 @@ switch_light(void)
/* redraw chart */ /* redraw chart */
for (i = 0; i < MAX_HISTORY; i++) { for (i = 0; i < MAX_HISTORY; i++) {
h = (21 * history[j]) / 100; 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--; j--;
if (j < 0) j = MAX_HISTORY - 1; if (j < 0) j = MAX_HISTORY - 1;
} }
/* show */
dockapp_copy2window(pixmap);
} }
static void static void
@ -259,15 +268,16 @@ draw_digit(int per)
} }
/* draw digit */ /* 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) { 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) { if (v100 == 1) {
dockapp_copyarea(parts, pixmap, 10, y, 10, 20, 5, 7); dockapp_copy2window(parts, 10, y, 10, 20, 5, 7);
dockapp_copyarea(parts, pixmap, 0, y, 10, 20, 17, 7); dockapp_copy2window(parts, 0, y, 10, 20, 17, 7);
dockapp_copyarea(parts, pixmap, 0, y, 10, 20, 29, 7); dockapp_copy2window(parts, 0, y, 10, 20, 29, 7);
} }
} }
@ -275,20 +285,17 @@ draw_digit(int per)
static void static void
draw_cpunumber(void) draw_cpunumber(void)
{ {
int x_offset = 0; int x, v1 = 0, v2 = 0;
int v10 = 0, v1 = 0;
v10 = cpu_opts.cpu_number / 10; v2 = cpu_opts.cpu_number / 10;
v1 = cpu_opts.cpu_number - v10 * 10; v1 = cpu_opts.cpu_number - v2 * 10;
if (backlight == LIGHTON) { x = backlight == LIGHTON ? 50 : 0;
x_offset = 50;
}
if (v10) { if (v2)
dockapp_copyarea(parts, pixmap, x_offset + v10 * 5, 40, 5, 9, 44, 10); dockapp_copy2window(parts, x + v2 * 5, 40, 5, 9, 44, 10);
}
dockapp_copyarea(parts, pixmap, x_offset + v1 * 5, 40, 5, 9, 50, 10); dockapp_copy2window(parts, x + v1 * 5, 40, 5, 9, 50, 10);
} }
#endif #endif
@ -362,33 +369,6 @@ parse_arguments(int argc, char **argv)
i++; 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 #ifdef USE_SMP
else if (!strcmp(argv[i], "--cpu") || !strcmp(argv[i], "-c")) { else if (!strcmp(argv[i], "--cpu") || !strcmp(argv[i], "-c")) {
int integer; int integer;
@ -412,13 +392,6 @@ parse_arguments(int argc, char **argv)
print_help(argv[0]), exit(1); 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 static void
@ -429,23 +402,29 @@ print_help(char *prog)
printf(" -d, --display <string> display to use\n"); printf(" -d, --display <string> display to use\n");
printf(" -t, --title <string> application title name\n"); printf(" -t, --title <string> application title name\n");
printf(" -bl, --backlight turn on back-light\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(" -lc, --light-color <string> "
printf(" -i, --interval <number> number of secs between updates (1 is default)\n"); "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 #ifdef USE_SMP
printf(" -c, --cpu <number> CPU number (0, 1, ... )\n"); printf(" -c, --cpu <number> "
"which CPU is monitored (0, 1, ... )\n");
#endif #endif
#ifdef IGNORE_NICE #ifdef IGNORE_NICE
printf(" -n, --ignore-nice ignore a nice value\n"); 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 #endif
printf(" -h, --help show this help text and exit\n"); printf(" -h, --help show this help text and exit\n");
printf(" -v, --version show program version and exit\n"); printf(" -v, --version show program version and exit\n");
printf(" -w, --windowed run the application in windowed mode\n"); printf(" -w, --windowed "
printf(" -wp, --windowed-withpanel run the application in windowed mode\n"); "run the application in windowed mode\n");
printf(" -wp, --windowed-withpanel "
"run the application in windowed mode\n");
printf(" with background panel\n"); printf(" with background panel\n");
printf(" -bw, --broken-wm activate broken window manager fix\n"); printf(" -bw, --broken-wm "
printf(" -a, --alarm <percentage> activate alarm mode. <percentage> is threshold\n"); "activate broken window manager fix\n");
printf(" of percentage from 0 to 100.(90 is default)\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: */