[Pkg-wmaker-commits] [wmload] 01/58: Imported Upstream version 0.9.2
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:36:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmload.
commit 9f05dfc30bda868f793e9ed6cca589527d5b7a90
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Sun Mar 1 01:03:01 2015 -0600
Imported Upstream version 0.9.2
---
INSTALL | 8 +
Imakefile | 17 +++
README | 189 ++++++++++++++++++++++++
back.xpm | 118 +++++++++++++++
mask.xpm | 67 +++++++++
mask2.xbm | 35 +++++
wmload.c | 491 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 925 insertions(+)
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..2217d98
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,8 @@
+1. Check the Imakefile to see if all the LIBS are ok for your system.
+ ALSO, check DESTDIR and BINDIR; as they are now, a `make install'
+ will put the wmload binary in /usr/local/bin.
+2. `xmkmf'
+3. `make'
+4. `make install'
+5. Enjoy!!!! (;-)
+
diff --git a/Imakefile b/Imakefile
new file mode 100644
index 0000000..d91cbce
--- /dev/null
+++ b/Imakefile
@@ -0,0 +1,17 @@
+/* installation directory is the combination of $(DESTDIR) and $(BINDIR)*/
+DESTDIR = /usr/local
+BINDIR = /bin
+
+XPMLIB = -L/usr/lib/X11 -lXpm -lm
+DEPLIBS = $(DEPXLIB)
+
+LOCAL_LIBRARIES = $(XPMLIB) $(XLIB)
+
+LINTLIBS = $(LINTXLIB)
+
+EXTRA_DEFINES = -Debug /* CFLAGS = -Debug */
+
+SRCS = wmload.c
+OBJS = wmload.o
+
+ComplexProgramTarget(wmload)
diff --git a/README b/README
new file mode 100644
index 0000000..4ce5e1e
--- /dev/null
+++ b/README
@@ -0,0 +1,189 @@
+>================================================<
+wmload - WindowMaker load gauge
+Updated, cleaned up and "fixed"
+==================================================
+VERSION: 0.9.2
+RELEASE DATE: 17 July 1997
+
+ -Minor cosmetic changes.
+ The graph zone is now perfectly square, 54x54.
+ <I didn't like it's odd width! (;-)>
+
+ -All values dealing with pixmap size have been
+ adjusted to accomodate the new `look'.
+
+VERSION: 0.9.1
+RELEASE DATE: 8 July 1997
+
+ -Uses correct ordering of PROC data.
+
+ -Increases the differentiation between tones,
+ just a smidgion.
+
+ -Catches a "Once In A Blue Moon" condition.
+ Under various circumstances rounding error
+ results in a pixel count of 55 or 53.
+ To prevent the 55 count from writing one
+ pixel into the edge of the frame, wmload
+ now catches these occurrences and corrects
+ for them.
+
+VERSION: 0.9.0
+RELEASE DATE: 6 July 1997
+
+ -Fixed the grayscale problem that occurred
+ whenever the "-shape" argument was used.
+
+ -Implemented the "-led" argument...
+ ...the last release had the argument,
+ however it wasn't implemented...
+ ...ie: it did nothing.
+ Called without the "-led" argument, wmload
+ uses it's default color "LightSeaGreen"
+ [which is the same as the asclock readout].
+ Called with the argument, it uses the
+ named color. If the default color is
+ unavailable, or the named color is invalid,
+ wmload simply uses the 3 green tones
+ found in the "back.xpm" pixmap.
+
+ -Added a "-ver" argument...
+ When used, it prints the current version
+ on stdout. If it is called alone with no
+ other arguments, wmload exits after
+ printing its' version. Called with other
+ arguments... wmload prints its' version
+ and continues as normal.
+
+ -Trapped bad arguments that don't start
+ with "-".
+
+ -Cleaned up the code a bit.
+
+ -Removed unnecessary files from the
+ distribution. <kept README's though>
+
+NOTE:
+ This is a load monitor which is designed
+ to work with the PROC filesystem. Generally
+ all Linux systems come with the PROC fs.
+ If you're using a different Unix and it
+ doesn't have the PROC fs, first see if
+ there is one available... otherwise this
+ monitor won't work!
+ Work is currently underway to produce a
+ more `portable' wmload that Solaris/Sun/HP etc.
+ users can also enjoy.
+
+INSTALL:
+ 1. Check the Imakefile to see if all the
+ LIBS are ok for your system.
+ ALSO, check DESTDIR and BINDIR; as they
+ are now, a `make install' will put the
+ wmload binary in /usr/local/bin.
+ 2. `xmkmf'
+ 3. `make'
+ 4. `make install'
+ 5. Enjoy!!!! (;-)
+
+SUGGESTED INVOCATION (for WindowMaker!):
+ `wmload -shape -withdrawn &'
+
+ OR for a different graph color:
+ `wmload -led ??? -shape -withdrawn &'
+ ...replace "???" with a color name
+ eg. green, red, orange, yellow, orchid, purple....
+ any of your systems standard X color symbols.
+
+SUGGESTED INVOCATION (for AfterStep):
+ To load wmload in Wharf, add a line in .steprc:
+*Wharf wmload nil MaxSwallow "wmload" wmload -led green -shape &
+ ...or to run it as a normal app: wmload -led "???" &
+ NOTE: AfterStep doesn't require the "-withdrawn" option.
+
+AVAILABILITY:
+ The latest release should be available from:
+ ftp://afterstep.foo.net/pub/apps/wmload/
+ http://www.bc1.com/users/rland/
+
+TODO LIST:
+ -Implement alternative `load' algorithms?
+
+LIABILITY & USABILITY:
+ As usual, this software is bound by the
+ GNU public license. You can use it however
+ you see fit, as long as all the README's
+ accompany any copy/version of it.
+ THE KIND SOLES WHO HAVE WRITTEN/CONTRIBUTED
+ TO THIS SOFTWARE, IN NO WAY ACCEPT LIABILITY
+ OR ANY RESPONSIBILITY FOR THE USE OF, OR FOR
+ ANY CONSEQUENCES RESULTING FROM THE USE OF
+ THIS SOFTWARE.
+ ...that having been said, I think you'll
+ like this new version and shouldn't have
+ problems with it. Happy load monitoring!
+
+FEEDBACK etc:
+ Maintainer of the current version...
+ Ryan Land, rland at bc1.com
+
+
+
+ ---<o>---
+
+
+
+the contents of the initial WM patch and original
+asload README's now follow...
+
+>================================================<
+wmload - WindowMaker performance monitor
+adapted from asload by Nic Bernstein
+==================================================
+ added withdrawn option, added WM hints.
+ changed trace color
+
+
+original README contents follow...
+
+>================================================<
+asload - afterstep performance monitor
+the best perfmonitor for the best X-windowmanager!
+==================================================
+
+RELEASE 1
+ 30th November 1996
+ by Beat Christen, bchriste at iiic.ethz.ch
+
+
+VERSION 0.1
+
+
+AVAILABILITY
+ the latest release should be available from
+
+ ftp://sunsite.unc.edu/pub/Linux/X11/xutils/asload.tgz
+ http://rif3.ethz.ch:1313/spiff/asload/asload.tgz
+
+INSTALL
+ 1. Check in the Imakefile if all LIBS are ok for your system.
+ 2. `make` (Send me the output if this fails)
+
+
+TODO
+ write a todo list.
+
+FEEDBACK
+ I prefer uuencoded mail.
+ You can register this software at
+ http://rif3.ethz.ch:1313/spiff/asload/register.html
+
+AUTHOR
+ Beat Christen
+
+CONTRIBUTORS
+
+CHANGES
+ 28Nov96 First Version for Linux /proc
+
+END OF FILE
diff --git a/back.xpm b/back.xpm
new file mode 100644
index 0000000..f8f02b9
--- /dev/null
+++ b/back.xpm
@@ -0,0 +1,118 @@
+/* XPM */
+static char *back_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 64 64 47 1",
+/* colors */
+". c #010103",
+"# c #818183",
+"a c #414143",
+"b c #c1c1c3",
+"c c #a1a1a3",
+"d c #616163",
+"e c #919193",
+"f c #515153",
+"g c #b1b1b3",
+"h c #717173",
+"i c #29292b",
+"j c #fdfdfb",
+"k c #cdcdcb",
+"l c #353533",
+"m c #89898b",
+"n c #49494b",
+"o c #a9a9ab",
+"p c #69696b",
+"q c #99999b",
+"r c #59595b",
+"s c #b9b9bb",
+"t c #79797b",
+"u c #bdbdbb",
+"v c #c9c9cb",
+"w c #3d3d3b",
+"x c #313133",
+"y c #7d7d7b",
+"z c #d1d1d3",
+"A c #39393b",
+"B c #858583",
+"C c #454543",
+"D c #c5c5c3",
+"E c #a5a5a3",
+"F c #656563",
+"G c #959593",
+"H c #555553",
+"I c #b5b5b3",
+"J c #757573",
+"K c #8d8d8b",
+"L c #4d4d4b",
+"M c #adadab",
+"N c #6d6d6b",
+"O c #9d9d9b",
+"P c #5d5d5b",
+"Q c #009f00",
+"R c #00a600",
+"S c #00b600",
+/* pixels */
+"qqqqqqqqqqqqqqqOOOOOOccccccEEEEEEEooooooMMMMMMggggggIIIIIIIIsssN",
+"OOOOOOOOOOOOOOOqOOOccOOcccEcEEEEEoEEoooMoMMgggMgggIIgIIIssubbDGC",
+"qqxxxxxxxxxxxlAAAwwwaaaCnnLLLffffHrHrPPddddFpppNNNNhhJJJttyyy#AC",
+"qqxxxlllllllAAAAwwaaaCCnnnLLfffHHrHPPPdddFpppNNNhhJJhJtttyy#BBwC",
+"OqllxlllllAAwwwaaaCCCnnnLLfffHrrrPrPdddFpFpppNNhhhhtJttyy##BBBaC",
+"OOxll.....................................................iBBman",
+"OOxll.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijmmman",
+"Oqxll.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijmmKCC",
+"OOxxl.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijKmKCn",
+"OOxll.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijKKKnn",
+"OOxxl.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijKeenn",
+"OclAA.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijeeeCL",
+"OOxAA.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijeeGnL",
+"OOAAw.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijeGGnn",
+"ccAAw.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijeGGnL",
+"ccAww.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijqGqLL",
+"ccAwa.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijGGGLL",
+"EEwwa.QRSiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijqqOnL",
+"Ecwaa.QRSiiiiiiiiiiiiiiiiiiiiiii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@ -0,0 +1,67 @@
+/* XPM */
+static char *mask_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 54 54 6 1",
+/* colors */
+". c #000000",
+"# c #282828",
+"a c #ffffff",
+"b c #5a5a5a",
+"c c #979797",
+"d c #e6e6e6",
+/* pixels */
+".....................................................#",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+".bcd#################################################a",
+"#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+};
diff --git a/mask2.xbm b/mask2.xbm
new file mode 100644
index 0000000..a28f4fb
--- /dev/null
+++ b/mask2.xbm
@@ -0,0 +1,35 @@
+#define mask2_width 54
+#define mask2_height 54
+static unsigned char mask2_bits[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
diff --git a/wmload.c b/wmload.c
new file mode 100644
index 0000000..cad9970
--- /dev/null
+++ b/wmload.c
@@ -0,0 +1,491 @@
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+#include <time.h>
+#include <math.h>
+#include <fcntl.h>
+#include <X11/Xatom.h>
+
+#include "back.xpm"
+#include "mask2.xbm"
+#include "mask.xpm"
+
+#define major_VER 0
+#define minor_VER 9
+#define patch_VER 2
+#define MW_EVENTS (ExposureMask | ButtonPressMask | StructureNotifyMask)
+#define FALSE 0
+#define Shape(num) (ONLYSHAPE ? num-5 : num)
+#define NCPUSTATES 4
+
+/* Global Data storage/structures ********************************************/
+static long cp_time[NCPUSTATES];
+static long last[NCPUSTATES];
+int ONLYSHAPE=0; /* default value is noshape */
+int updatespeed = 4;
+static char *help_message[] = {
+"where options include:",
+" -u <secs> updatespeed",
+" -exe <program> program to start on click",
+" -led <color> color of the led",
+" -position [+|-]x[+|-]y position of wmload",
+" -shape without groundplate",
+" -iconic start up as icon",
+" -withdrawn start up withdrawn",
+" -ver output version",
+NULL
+};
+
+/* X11 Variables *************************************************************/
+Display *dpy; /* welches DISPLAY */
+Window Root; /* Hintergrund-Drawable */
+int screen;
+int x_fd;
+int d_depth;
+XSizeHints mysizehints;
+XWMHints mywmhints;
+Pixel back_pix, fore_pix;
+GC NormalGC;
+Window iconwin, win; /* My home is my window */
+char *ProgName;
+char *Geometry;
+char *LedColor = "LightSeaGreen";
+char Execute[] = "echo no program has been specified >/dev/console";
+char *ERR_colorcells = "not enough free color cells\n";
+char *ampers = " &";
+
+/* XPM Structures & Variables ************************************************/
+typedef struct _XpmIcon {
+ Pixmap pixmap;
+ Pixmap mask;
+ XpmAttributes attributes;
+} XpmIcon;
+
+XpmIcon wmload;
+XpmIcon visible;
+time_t actualtime;
+long actualmin;
+
+/* Function definitions ******************************************************/
+void GetXPM(void);
+Pixel GetColor(char *name);
+void RedrawWindow( XpmIcon *v);
+void InitLoad();
+void InsertLoad();
+
+/*****************************************************************************/
+/* Source Code <--> Function Implementations */
+/*****************************************************************************/
+void usage()
+{
+ char **cpp;
+
+ fprintf(stderr,"\nusage: %s [-options ...] \n", ProgName);
+ for (cpp = help_message; *cpp; cpp++) {
+ fprintf(stderr, "%s\n", *cpp);
+ }
+ fprintf(stderr,"\n");
+ exit(1);
+}
+
+int main(int argc,char *argv[])
+{
+ int i;
+ unsigned int borderwidth ;
+ char *display_name = NULL;
+ char *wname = "wmload";
+ XGCValues gcv;
+ unsigned long gcm;
+ XEvent Event;
+ XTextProperty name;
+ XClassHint classHint;
+ Pixmap pixmask;
+ Geometry = "";
+ mywmhints.initial_state = NormalState;
+
+ /* Parse command line options */
+ ProgName = argv[0];
+
+ for(i=1;i<argc;i++) {
+ char *arg= argv[i];
+
+ if (arg[0] == '-') {
+ switch(arg[1]) {
+ case 'u':
+ if(++i >=argc) usage();
+ sscanf(argv[i], "%d", &updatespeed);
+ continue;
+ case 'e':
+ if(++i >=argc) usage();
+ strcpy(&Execute[0], argv[i]);
+ strcat(&Execute[0], " &");
+ continue;
+ case 's':
+ ONLYSHAPE=1;
+ continue;
+ case 'p':
+ if(++i >=argc) usage();
+ Geometry = argv[i];
+ continue;
+ case 'i':
+ mywmhints.initial_state = IconicState;
+ continue;
+ case 'w':
+ mywmhints.initial_state = WithdrawnState;
+ continue;
+ case 'l':
+ if(++i >=argc) usage();
+ LedColor = argv[i];
+ continue;
+ case 'v':
+ fprintf(stdout, "\nwmload version: %i.%i.%i\n", major_VER, minor_VER, patch_VER);
+ if(argc == 2) exit(0);
+ continue;
+ default:
+ usage();
+ }
+ }
+ else
+ {
+ fprintf(stderr, "\nInvalid argument: %s\n", arg);
+ usage();
+ }
+ }
+
+ /* Open the display */
+ if (!(dpy = XOpenDisplay(display_name)))
+ {
+ fprintf(stderr,"wmload: can't open display %s\n",
+ XDisplayName(display_name));
+ exit (1);
+ }
+
+ screen= DefaultScreen(dpy);
+ Root = RootWindow(dpy, screen);
+ d_depth = DefaultDepth(dpy, screen);
+ x_fd = XConnectionNumber(dpy);
+
+ /* Convert XPM Data to XImage */
+ GetXPM();
+
+ /* Create a window to hold the banner */
+ mysizehints.flags= USSize|USPosition;
+ mysizehints.x = 0;
+ mysizehints.y = 0;
+
+ back_pix = GetColor("white");
+ fore_pix = GetColor("black");
+
+ XWMGeometry(dpy, screen, Geometry, NULL, (borderwidth =1), &mysizehints,
+ &mysizehints.x,&mysizehints.y,&mysizehints.width,&mysizehints.height, &i);
+
+ mysizehints.width = wmload.attributes.width;
+ mysizehints.height= wmload.attributes.height;
+
+ win = XCreateSimpleWindow(dpy,Root,mysizehints.x,mysizehints.y,
+ mysizehints.width,mysizehints.height,
+ borderwidth,fore_pix,back_pix);
+ iconwin = XCreateSimpleWindow(dpy,win,mysizehints.x,mysizehints.y,
+ mysizehints.width,mysizehints.height,
+ borderwidth,fore_pix,back_pix);
+
+ /* activate hints */
+ XSetWMNormalHints(dpy, win, &mysizehints);
+ classHint.res_name = "wmload";
+ classHint.res_class = "WMLoad";
+ XSetClassHint(dpy, win, &classHint);
+
+ XSelectInput(dpy,win,MW_EVENTS);
+ XSelectInput(dpy,iconwin,MW_EVENTS);
+ XSetCommand(dpy,win,argv,argc);
+
+ if (XStringListToTextProperty(&wname, 1, &name) ==0) {
+ fprintf(stderr, "wmload: can't allocate window name\n");
+ exit(-1);
+ }
+ XSetWMName(dpy, win, &name);
+
+ /* Create a GC for drawing */
+ gcm = GCForeground|GCBackground|GCGraphicsExposures;
+ gcv.foreground = fore_pix;
+ gcv.background = back_pix;
+ gcv.graphics_exposures = FALSE;
+ NormalGC = XCreateGC(dpy, Root, gcm, &gcv);
+
+ if (ONLYSHAPE) { /* try to make shaped window here */
+ pixmask = XCreateBitmapFromData(dpy, win, mask2_bits, mask2_width,
+ mask2_height);
+ XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
+ XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
+ }
+
+ mywmhints.icon_window = iconwin;
+ mywmhints.icon_x = mysizehints.x;
+ mywmhints.icon_y = mysizehints.y;
+ mywmhints.window_group = win;
+ mywmhints.flags = StateHint | IconWindowHint | IconPositionHint
+ | WindowGroupHint;
+ XSetWMHints(dpy, win, &mywmhints);
+
+ XMapWindow(dpy,win);
+ InitLoad();
+ InsertLoad();
+ RedrawWindow(&visible);
+ while(1)
+ {
+ if (actualtime != time(0))
+ {
+ actualtime = time(0);
+
+ if(actualtime % updatespeed == 0)
+ InsertLoad();
+
+ RedrawWindow(&visible);
+ }
+
+ /* read a packet */
+ while (XPending(dpy))
+ {
+ XNextEvent(dpy,&Event);
+ switch(Event.type)
+ {
+ case Expose:
+ if(Event.xexpose.count == 0 )
+ RedrawWindow(&visible);
+ break;
+ case ButtonPress:
+ system(Execute);
+ break;
+ case DestroyNotify:
+ XFreeGC(dpy, NormalGC);
+ XDestroyWindow(dpy, win);
+ XDestroyWindow(dpy, iconwin);
+ XCloseDisplay(dpy);
+ exit(0);
+ default:
+ break;
+ }
+ }
+ XFlush(dpy);
+#ifdef SYSV
+ poll((struct poll *) 0, (size_t) 0, 50);
+#else
+ usleep(50000L); /* 5/100 sec */
+#endif
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+void nocolor(char *a, char *b)
+{
+ fprintf(stderr,"wmload: can't %s %s\n", a,b);
+}
+
+/*****************************************************************************/
+/* convert the XPMIcons to XImage */
+void GetXPM(void)
+{
+ static char **alt_xpm;
+ XColor col;
+ XWindowAttributes attributes;
+ int ret;
+ char tempc1[12],tempc2[12],tempc3[12];
+ float colr,colg,colb;
+
+ alt_xpm =ONLYSHAPE ? mask_xpm : back_xpm;
+
+ /* for the colormap */
+ XGetWindowAttributes(dpy,Root,&attributes);
+
+ /* get user-defined color or validate the default */
+ if (!XParseColor (dpy, attributes.colormap, LedColor, &col))
+ {
+ nocolor("parse",LedColor);
+ }
+ else
+ {
+ /* scale down the Xcolor values */
+ colr = col.red / 257;
+ colg = col.green / 257;
+ colb = col.blue / 257;
+ /* the brightest color */
+ sprintf(tempc1, "S c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
+ back_xpm[47] = tempc1;
+
+ /* make medium color */
+ colr = (colr /100) *89;
+ colg = (colg /100) *89;
+ colb = (colb /100) *89;
+ sprintf(tempc2, "R c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
+ back_xpm[46] = tempc2;
+
+ /* make darkest color */
+ colr = (colr /100) *89;
+ colg = (colg /100) *89;
+ colb = (colb /100) *89;
+ sprintf(tempc3, "Q c #%.2x%.2x%.2x", (int)colr, (int)colg, (int)colb);
+ back_xpm[45] = tempc3;
+ }
+
+ wmload.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
+ ret = XpmCreatePixmapFromData(dpy, Root, alt_xpm, &wmload.pixmap,
+ &wmload.mask, &wmload.attributes);
+ if(ret != XpmSuccess)
+ {fprintf(stderr, ERR_colorcells);exit(1);}
+
+ visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
+ ret = XpmCreatePixmapFromData(dpy, Root, back_xpm, &visible.pixmap,
+ &visible.mask, &visible.attributes);
+ if(ret != XpmSuccess)
+ {fprintf(stderr, ERR_colorcells);exit(1);}
+
+}
+
+/*****************************************************************************/
+/* Removes expose events for a specific window from the queue */
+int flush_expose (Window w)
+{
+ XEvent dummy;
+ int i=0;
+
+ while (XCheckTypedWindowEvent (dpy, w, Expose, &dummy))i++;
+ return i;
+}
+
+/*****************************************************************************/
+/* Draws the icon window */
+void RedrawWindow( XpmIcon *v)
+{
+ flush_expose (iconwin);
+ XCopyArea(dpy,v->pixmap,iconwin,NormalGC,
+ 0,0,v->attributes.width, v->attributes.height,0,0);
+ flush_expose (win);
+ XCopyArea(dpy,v->pixmap,win,NormalGC,
+ 0,0,v->attributes.width, v->attributes.height,0,0);
+
+}
+
+/*****************************************************************************/
+Pixel GetColor(char *name)
+{
+ XColor color;
+ XWindowAttributes attributes;
+
+ XGetWindowAttributes(dpy,Root,&attributes);
+ color.pixel = 0;
+ if (!XParseColor (dpy, attributes.colormap, name, &color))
+ {
+ nocolor("parse",name);
+ }
+ else if(!XAllocColor (dpy, attributes.colormap, &color))
+ {
+ nocolor("alloc",name);
+ }
+ return color.pixel;
+}
+
+/*****************************************************************************/
+void InitLoad()
+{
+ /* Save the 4 base colors in wmload */
+ XCopyArea(dpy, visible.pixmap, wmload.pixmap, NormalGC,
+ 6,6,3,52, Shape(6), Shape(6));
+
+ /* Copy the base panel to visible */
+ XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
+ 0,0,mysizehints.width, mysizehints.height, 0 ,0);
+
+ /* Remove the 4 base colors from visible */
+ XCopyArea(dpy, visible.pixmap, visible.pixmap, NormalGC,
+ Shape(9),Shape(6),3,52, Shape(6), Shape(6));
+}
+
+static char *
+skip_token(const char *p)
+{
+ while (isspace(*p)) p++;
+ while (*p && !isspace(*p)) p++;
+ return (char *)p;
+}
+
+void GetLoad(int Maximum, int *usr, int *nice, int *sys, int *free)
+{
+ char buffer[100];/*[4096+1];*/
+ int fd, len;
+ int total;
+ char *p;
+
+ fd = open("/proc/stat", O_RDONLY);
+ len = read(fd, buffer, sizeof(buffer)-1);
+ close(fd);
+ buffer[len] = '\0';
+
+ p = skip_token(buffer); /* "cpu" */
+
+ cp_time[0] = strtoul(p, &p, 0); /* user */
+ cp_time[1] = strtoul(p, &p, 0); /* nice */
+ cp_time[2] = strtoul(p, &p, 0); /* system */
+ cp_time[3] = strtoul(p, &p, 0); /* idle */
+
+ *usr = cp_time[0] - last[0];
+ *nice = cp_time[1] - last[1];
+ *sys = cp_time[2] - last[2];
+ *free = cp_time[3] - last[3];
+ total = *usr + *nice + *sys + *free;
+
+ last[0] = cp_time[0];
+ last[1] = cp_time[1];
+ last[2] = cp_time[2];
+ last[3] = cp_time[3];
+
+ *usr = rint(Maximum * (float)(*usr) /total);
+ *nice =rint(Maximum * (float)(*nice) /total);
+ *sys = rint(Maximum * (float)(*sys) /total);
+ *free = rint(Maximum * (float)(*free) /total);
+}
+
+void InsertLoad()
+{
+ int UserTime, NiceTime, SystemTime, FreeTime, act, constrain;
+ GetLoad( 52, &UserTime, &NiceTime, &SystemTime, &FreeTime);
+
+ constrain = (UserTime + NiceTime + SystemTime + FreeTime);
+ if(constrain == 53)
+ {
+ if(FreeTime > 0) FreeTime--;
+ else if(SystemTime > 0) SystemTime--;
+ else if(NiceTime > 0) NiceTime--;
+ else if(UserTime > 0) UserTime--;
+ }
+ else if(constrain == 51) FreeTime++;
+
+ /* Move the area */
+ XCopyArea(dpy, visible.pixmap, visible.pixmap, NormalGC,
+ Shape(7), Shape(6), 51, 52, Shape(6), Shape(6));
+
+
+ /* User Time */
+ act = 58 - UserTime;
+ if(UserTime > 0)
+ XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
+ Shape(6), Shape(6), 1, UserTime, Shape(57), Shape(act));
+
+ /* Nice Time */
+ act = act - NiceTime;
+ if(NiceTime > 0)
+ XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
+ Shape(7), Shape(6), 1, NiceTime, Shape(57), Shape(act));
+
+ /* System Time */
+ act = act - SystemTime;
+ if(SystemTime > 0)
+ XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
+ Shape(8), Shape(6), 1, SystemTime, Shape(57), Shape(act));
+
+ /* Free Time */
+ if(FreeTime > 0)
+ XCopyArea(dpy, wmload.pixmap, visible.pixmap, NormalGC,
+ Shape(9), Shape(6), 1, FreeTime, Shape(57), Shape(6));
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmload.git
More information about the Pkg-wmaker-commits
mailing list