pax_global_header00006660000000000000000000000064125615365540014526gustar00rootroot0000000000000052 comment=0d7c0684e8c34aa01737dfea5ec474a1b90bb171 wmsysmon-master/000077500000000000000000000000001256153655400142575ustar00rootroot00000000000000wmsysmon-master/.gitignore000066400000000000000000000000331256153655400162430ustar00rootroot00000000000000src/wmsysmon src/*.o *.swp wmsysmon-master/COPYING000066400000000000000000000430761256153655400153240ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free 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 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 price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any 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 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this 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 themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering 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 void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot 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 may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes 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 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 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 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 Appendix: 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 free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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., 675 Mass Ave, Cambridge, MA 02139, 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) 19yy 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. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice 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 Library General Public License instead of this License. wmsysmon-master/ChangeLog000066400000000000000000000121371256153655400160350ustar00rootroot00000000000000-- end -- - Aug 4 2002 - Vito Caputo (swivel@gnugeneration.com) - * a few changes, i can't recall, the interrupt meters have been refined a bit, main event loop changed but theres a slight bug with the event loop timing, the timeout doesnt get updated dynamically if the main select() exits before the timeout... you can see this by say dragging an icon over wmsysmon a bunch, the meters will all shrink if interrupts are ocurring, because the time between polls of the interrupt counts is shorter than before, causing it to think theres less interrupts, when in fact, there was less time for them to occur, minor bug. - Dec 24 2001 - Vito Caputo (swivel@gnugeneration.com) - * minor cleanups, in wmgeneral.c added static int where was just static. (int is assumed but caused warning in -Wall), also removed some unused variables... - Dec 23 2001 - Vito Caputo (swivel@gnugeneration.com) - * removed profiling instrumentation, it's no longer needed. * updated meters, the behaviour is changed a bit, interrupts that never occur dont get the _ level so you can see which are inactive in the system, and they should be more responsive. * removed usleep() usage and switched to poll() with a timeout on the X connection fd, more efficient and allows expose events to be handled with less latency. - Jul 11 2000 - Vito Caputo (swivel@gnugeneration.com) - * eliminated the memcpy() used for copying interrupt statistics into backups for comparison in next iteration, now simply swaps pointers. * made new profile, organized existing profiles. - Jun 29 2000 - Vito Caputo (swivel@gnugeneration.com) - * added profiling instrumentation to code for TAU * optimized DrawMem() routine, which profiling revealed as being 96% of the total CPU time used in 0.6.0. * optimized DrawStuff() routine * added simple drawing management code, not quite drawing list but more efficient in most cases than blitting whole tile. Anything more complex will probably outweigh the benefits since we're dealing with such a small area. * removed some unused routines that were left behind from Dave Clarks release, and some junk in wmgeneral.c, next release may have no wmgeneral.c, even though it would be pointless to remove it since the same code would be sitting in wmsysmon.c, its probably more tidy as-is. * after extensive profiling, it has been discovered that polling /proc/meminfo is expensive no matter how you go about parsing it, linux 2.4 in theory does this faster, but I have changed the meminfo polling to be a fraction of the refresh rate used, this makes things alot more CPU (system) friendly. * fix to drawing management code, was not adding all dirty's properly * added small test program for benchmarking /proc/meminfo * line #'s are calculated at startup now for /proc/meminfo and /proc/stat entries we use, so no strchr()'s every iteration, and order changes in /proc/meminfo and /proc/stat formatting shouldnt break it. * some code cleanup * fix to Makefile, some systems were not finding includes in /usr/X11R6/include without -I/usr/X11R6/include - Apr 24 2000 - Vito Caputo (swivel@gnugeneration.com) - * added interrupt meters, i like i like :) * set intterrupt meters to default behavior, added -l to arguements to set old lights behavior and to help screen. * new feature, 0.6.0 now :) - Apr 2 2000 - Vito Caputo (swivel@gnugeneration.com) - * fixed some problems with parsing files in /proc, much much faster now. (toyed with drawing lists and some other things but broke most of wmsysmon, will be rewriting the stuff in wmgeneral.c eventually) - Mar 5 2000 - Vito Caputo (swivel@gnugeneration.com) - * fixed typo in HI_INTS version of help (wmsysmon -h) interrupts 0-24 to 0-23 * upped version # to 0.5.1 * another fix to the lights, Ignacy's fix fixed blinking but broke optimization (if lights were off they were always refreshed) - Mar 5 2000 - Ignacy Gawedzki (ouaou@relou.net) * little fix to the lights, which kept blinking. - Feb 12 2000 - Vito Caputo (swivel@gnugeneration.com) - * created this changelog * reformatted code to my liking * converted c++ style comments (bleh, ick) to C style. * upgraded version # to 0.5 * changed link to old non-maintained (dead?) wmsysmon site in usage to GNU Generation site with maintained wmsysmon. * added the ascii diagram to the usage dialog * removed wmgeneral/ and misc.c and list.c, pointless. * added proper GNU GPL notice to wmsysmon.c - Jan 25 2000 - Vito Caputo (swivel@gnugeneration.com) - * After sending updates to previous maintainer decided to simply takeover maintennance of wmsysmon, if anyone objects, tough, get off your a*s and maintain it yourself, nothings stopping you, behold the power of the GNU GPL. * optimized uptime refresh to only redraw uptime when changed * optimized swap & mem usage percent bars to only redraw when changed * optimized IO usage percent bar to only redraw when changed * optimized interrupt lites to only redraw when changed * rewrote Makefile, chaged ALPHA_VERSION to HI_INTS (SMP x86 boxes use this too so its not alpha only) -- begin -- wmsysmon-master/README000066400000000000000000000027031256153655400151410ustar00rootroot00000000000000You have downloaded wmsysmon, a small dock application for use with WindowMaker (www.windowmaker.org) to show system information on interrupt activity, memory use, swap use, and IO. wmsysmon was originally written by Dave Clark, I saw room for improvement in wmsysmon and sent some updates in to Dave Clark, after nearly a month went by with no response I decided to takeover development. Dave Clark is OK with this, it appears he is too overworked to keep up with everything, if you are management over Dave Clark give him a break :). This program is licensed under the GNU GPL, see file COPYING. Simply enter the 'src' directory and type 'make' to build wmsysmon, if you are using a SMP x86 machine or an alpha machine you may want to edit the Makefile and uncomment -DHI_INTS before building, this enables monitoring the 24 interrupts available on such machines. After building successfully, execute 'make install' to install the binary into /usr/local/bin, root will be required to write the binary in /usr/local/bin, but it is not required to install the binary in /usr/local/bin to use wmsysmon, it may be run from anywhere in the filesystem, but on a multi-user system it is preferred to have it available for everyone to use, hence /usr/local/bin. For information on running wmsysmon, execute 'wmsysmon -h' after building (and installing) using the above instructions. Cheers. - Vito Caputo swivel@gnugeneration.com GNU Generation www.gnugeneration.com wmsysmon-master/src/000077500000000000000000000000001256153655400150465ustar00rootroot00000000000000wmsysmon-master/src/Makefile000066400000000000000000000012031256153655400165020ustar00rootroot00000000000000CC = gcc PREFIX ?= /usr/local LIBDIR += -L/usr/X11R6/lib LIBS = $(shell pkg-config --libs xpm xext x11) -lm #CFLAGS = -g #-DMONDEBUG CFLAGS += -Wall -O3 -fomit-frame-pointer $(shell pkg-config --cflags xpm xext x11) #-DHI_INTS #undefine HI_INTS if your x86 SMP or alpha BIN = wmsysmon OBJS = wmgeneral.o \ wmsysmon.o $(BIN): $(OBJS) $(CC) $(LDFLAGS) -o $(BIN) $(OBJS) $(LIBDIR) $(LIBS) all: wmsysmon clean: rm -f $(OBJS) $(BIN) install: mkdir -p $(DESTDIR)$(PREFIX)/bin install -g root -o root $(BIN) $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 install -m 644 wmsysmon.1 $(DESTDIR)$(PREFIX)/share/man/man1 wmsysmon-master/src/wmgeneral.c000066400000000000000000000175001256153655400171760ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "wmgeneral.h" Window Root; int screen; int x_fd; int d_depth; XSizeHints mysizehints; XWMHints mywmhints; Pixel back_pix, fore_pix; char *Geometry = ""; Window iconwin, win; GC NormalGC; XpmIcon wmgen; Pixmap pixmask; static void GetXPM(XpmIcon *, char **); static Pixel GetColor(char *); void RedrawWindow(void); static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) { XWindowAttributes attributes; int err; /* For the colormap */ XGetWindowAttributes(display, Root, &attributes); wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen->pixmap), &(wmgen->mask), &(wmgen->attributes)); wmgen->dirty_x = wmgen->attributes.width; wmgen->dirty_y = wmgen->attributes.height; wmgen->dirty_w = 0; wmgen->dirty_h = 0; if (err != XpmSuccess) { fprintf(stderr, "Not enough free colorcells.\n"); exit(1); } } static Pixel GetColor(char *name) { XColor color; XWindowAttributes attributes; XGetWindowAttributes(display, Root, &attributes); color.pixel = 0; if (!XParseColor(display, attributes.colormap, name, &color)) { fprintf(stderr, "wm.app: can't parse %s.\n", name); } else if (!XAllocColor(display, attributes.colormap, &color)) { fprintf(stderr, "wm.app: can't allocate %s.\n", name); } return color.pixel; } void RedrawWindow(void) { if (wmgen.dirty_w && wmgen.dirty_h) { XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, wmgen.dirty_x, wmgen.dirty_y, wmgen.dirty_w, wmgen.dirty_h, wmgen.dirty_x, wmgen.dirty_y); XCopyArea(display, wmgen.pixmap, win, NormalGC, wmgen.dirty_x, wmgen.dirty_y, wmgen.dirty_w, wmgen.dirty_h, wmgen.dirty_x, wmgen.dirty_y); } #ifdef MONDEBUG printf("Dirty X: %i Y: %i width: %i height: %i\n", wmgen.dirty_x, wmgen.dirty_y, wmgen.dirty_w, wmgen.dirty_h); #endif XFlush(display); wmgen.dirty_x = wmgen.attributes.width; wmgen.dirty_y = wmgen.attributes.height; wmgen.dirty_w = 0; wmgen.dirty_h = 0; } void RedrawWindowXY(int x, int y) { XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0); XCopyArea(display, wmgen.pixmap, win, NormalGC, x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0); } void DirtyWindow(int x, int y, unsigned int w, unsigned int h) { int nx, ny, nw, nh; #ifdef MONDEBUG printf("currently dirty: X: %i Y: %i W: %u H: %u new: X: %i Y: %i W: %u H: %u\n", wmgen.dirty_x, wmgen.dirty_y, wmgen.dirty_w, wmgen.dirty_h, x, y, w, h); #endif if (x < wmgen.dirty_x) nx = x; else nx = wmgen.dirty_x; if (y < wmgen.dirty_y) ny = y; else ny = wmgen.dirty_y; if ((x + w) > (wmgen.dirty_x + wmgen.dirty_w)) nw = (x + w) - nx; else nw = (wmgen.dirty_x + wmgen.dirty_w) - nx; if ((y + h) > (wmgen.dirty_y + wmgen.dirty_h)) nh = (y + h) - ny; else nh = (wmgen.dirty_y + wmgen.dirty_h) - ny; wmgen.dirty_x = nx; wmgen.dirty_y = ny; wmgen.dirty_w = nw; wmgen.dirty_h = nh; #ifdef MONDEBUG printf("Dirty: X: %i Y: %i W: %i H: %i\n", wmgen.dirty_x, wmgen.dirty_y, wmgen.dirty_w, wmgen.dirty_h); #endif } void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { int i,j,k; int width, height, numcol, depth; int zero=0; unsigned char bwrite; int bcount; int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); for (k=0; k!=depth; k++) { zero <<=8; zero |= xpm[1][k]; } for (i=numcol+1; i < numcol+sy+1; i++) { bcount = 0; bwrite = 0; for (j=0; j>= 1; curpixel=0; for (k=0; k!=depth; k++) { curpixel <<=8; curpixel |= xpm[i][j+k]; } if (curpixel != zero) { bwrite += 128; } bcount++; if (bcount == 8) { *xbm = bwrite; xbm++; bcount = 0; bwrite = 0; } } } } void copyXPMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) { XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, sx, sy, w, h, dx, dy); DirtyWindow(dx, dy, w, h); } void copyXBMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) { XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, sx, sy, w, h, dx, dy); DirtyWindow(dx, dy, w, h); } void setMaskXY(int x, int y) { XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet); XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet); } int openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) { unsigned int borderwidth = 1; XClassHint classHint; char *display_name = NULL; char *wname = argv[0]; XTextProperty name; XGCValues gcv; unsigned long gcm; char *geometry = NULL; int dummy=0; int i, wx, wy, fd; for (i=1; argv[i]; i++) { if (!strcmp(argv[i], "-display")) { display_name = argv[i+1]; i++; } if (!strcmp(argv[i], "-geometry")) { geometry = argv[i+1]; i++; } } if (!(display = XOpenDisplay(display_name))) { fprintf(stderr, "%s: can't open display %s\n", wname, XDisplayName(display_name)); return -1; } fd = ConnectionNumber(display); screen = DefaultScreen(display); Root = RootWindow(display, screen); d_depth = DefaultDepth(display, screen); x_fd = XConnectionNumber(display); /* Convert XPM to XImage */ GetXPM(&wmgen, pixmap_bytes); /* Create a window to hold the stuff */ mysizehints.flags = USSize | USPosition; mysizehints.x = 0; mysizehints.y = 0; back_pix = GetColor("white"); fore_pix = GetColor("black"); XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints, &mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy); mysizehints.width = 64; mysizehints.height = 64; DirtyWindow(0, 0, 64, 64); win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y, mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix); iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y, mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix); /* Activate hints */ XSetWMNormalHints(display, win, &mysizehints); classHint.res_name = wname; classHint.res_class = wname; XSetClassHint(display, win, &classHint); XSelectInput(display, win, ExposureMask | StructureNotifyMask); XSelectInput(display, iconwin, ExposureMask | StructureNotifyMask); if (XStringListToTextProperty(&wname, 1, &name) == 0) { fprintf(stderr, "%s: can't allocate window name\n", wname); return -1; } XSetWMName(display, win, &name); /* Create GC for drawing */ gcm = GCForeground | GCBackground | GCGraphicsExposures; gcv.foreground = fore_pix; gcv.background = back_pix; gcv.graphics_exposures = 0; NormalGC = XCreateGC(display, Root, gcm, &gcv); /* ONLYSHAPE ON */ pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height); XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet); XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet); /* ONLYSHAPE OFF */ mywmhints.initial_state = WithdrawnState; 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(display, win, &mywmhints); XSetCommand(display, win, argv, argc); XMapWindow(display, win); if (geometry) { if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) { fprintf(stderr, "Bad geometry string.\n"); return -1; } XMoveWindow(display, win, wx, wy); } return fd; } wmsysmon-master/src/wmgeneral.h000066400000000000000000000023561256153655400172060ustar00rootroot00000000000000#ifndef WMGENERAL_H_INCLUDED #define WMGENERAL_H_INCLUDED /***********/ /* Defines */ /***********/ #define MAX_MOUSE_REGION (16) /************/ /* Typedefs */ /************/ typedef struct _rckeys rckeys; struct _rckeys { const char *label; char **var; }; typedef struct _rckeys2 rckeys2; struct _rckeys2 { const char *family; const char *label; char **var; }; typedef struct { Pixmap pixmap; Pixmap mask; XpmAttributes attributes; int dirty_x, dirty_y; unsigned int dirty_w, dirty_h; } XpmIcon; /*******************/ /* Global variable */ /*******************/ Display *display; /***********************/ /* Function Prototypes */ /***********************/ void AddMouseRegion(int index, int left, int top, int right, int bottom); int CheckMouseRegion(int x, int y); int openXwindow(int argc, char *argv[], char **, char *, int, int); void RedrawWindow(void); void RedrawWindowXY(int x, int y); void createXBMfromXPM(char *, char **, int, int); void copyXPMArea(int, int, unsigned int, unsigned int, int, int); void copyXBMArea(int, int, unsigned int, unsigned int, int, int); void setMaskXY(int, int); void parse_rcfile(const char *, rckeys *); inline void DirtyWindow(int, int, unsigned int, unsigned int); #endif wmsysmon-master/src/wmsysmon-master-alpha.xpm000066400000000000000000000621001256153655400220430ustar00rootroot00000000000000/* XPM */ static char * wmsysmon_master_xpm[] = { "240 100 80 1", ". c #0000FF", " c None", "+ c #202020", "@ c #000000", "# c #C7C3C7", "$ c #004941", "% c #20B2AE", "& c #107D79", "* c #188A86", "= c #007D71", "- c #00FF0F", "; c #04FA0F", "> c #09F50F", ", c #0DF10F", "' c #12EC0E", ") c #16E80E", "! c #1BE30E", "~ c #1FDF0D", "{ c #24DA0D", "] c #28D60D", "^ c #2DD10D", "/ c #32CC0C", "( c #36C80C", "_ c #3BC30C", ": c #3FBF0B", "< c #44BA0B", "[ c #48B60B", "} c #4DB10B", "| c #51AD0A", "1 c #56A80A", "2 c #5BA30A", "3 c #5F9F09", "4 c #649A09", "5 c #689609", "6 c #6D9109", "7 c #718D08", "8 c #768808", "9 c #7A8408", "0 c #7F7F07", "a c #847A07", "b c #887607", "c c #8D7107", "d c #916D06", "e c #966806", "f c #9A6406", "g c #9F5F05", "h c #A35B05", "i c #A85605", "j c #AD5105", "k c #B14D04", "l c #B64804", "m c #BA4404", "n c #BF3F03", "o c #C33B03", "p c #C83603", "q c #CC3203", "r c #D12D02", "s c #D62802", "t c #DA2402", "u c #DF1F01", "v c #E31B01", "w c #E81601", "x c #EC1201", "y c #F10D00", "z c #F50900", "A c #FA0400", "B c #FF0000", "C c #283C38", "D c #B60418", "E c #00EB00", "F c #0E7973", "G c #F7F3FF", "H c #11817B", "I c #E80426", "J c #71E371", "K c #138984", "L c #16918C", "M c #494949", "N c #7A7A7A", "O c #BCBCBC", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@###########################################################..+...............................................................................................................................................................................", "................................................................+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................", "................................................................+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................", "..@###########################################################..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "................................................................+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++%%%%+++$$$$&+&%%%%*+&%%%%&+&$$$$&+&%%%%&+&%%%%*+&%%%%&+&%%%%*+&%%%%*++++++................................................................................................", "..@###########################################################..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................", "................................................................+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................", "................................................................+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++++++................................................................................................", "................................................................+..++&$$$$&++$$$$&+&%%%%&+&%%%%&+&%%%%&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................", "..@+++++$$$+++$$$+++$$$++++++++$$$+++$$$+++++++$$$+++$$$+++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................", "..@++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+..+++%%%%+++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................", "..@++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "..@+++++$$$+++$$$+++$$$+++=++++$$$+++$$$+++=+++$$$+++$$$+++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "..@++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+...............................................................................................................................................................................", "..@++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+...............................................................................................................................................................................", "..@+++++$$$+++$$$+++$$$+++=++++$$$+++$$$+++=+++$$$+++$$$+++++#..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................", "..############################################################..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................", "................................................................+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................", "................................................................+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@@@@@@#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..###########################################....#############..+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+...............................................................................................................................................................................", "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................", "++%%%+++$$$=+=%%%=+=%%%=+=$$$=+=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+++++++++++++++++++.................................................................................................................................................................", "+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD++.+EE++.+CC++..........FFFF....++++....++++....++++....++++................................................................................................", "+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DGDD+.EGEE+.CCCC+..........HHHH....HHHH....++++....++++....+II+................................................................................................", "+=$$$=++$$$=+=%%%=++%%%=+=%%%=+=%%%=+=%%%=++$$$=+$%%%$+=%%%=++=++++=+++%+++++++..DDDD+.EEEE+.CCCC+..+%$J....KKKK....KKKK....KKKK....++++....+II+................................................................................................", "+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD++.+EE++.+CC++..........LLLL....LLLL....LLLL....LLLL....++++................................................................................................", "+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%++%++++%++%++++++++.................................................................................................................................................................", "++%%%+++$$$%+=%%%=+=%%%=++$$$=+=%%%=+=%%%=++$$$=+=%%%=+=%%%=++=++++=++%++++++++.................................................................................................................................................................", "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................", "................................................................................................................................................................................................................................................", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................", "+$%%%$+=%%%++=%%%=+=%%%++=%%%=+=%%%=+=%%%=+=$$$=++$$$=++$$$=+=$$$=+=$$$++%$$$%+=%%%++=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+=$$$=+=$$$=+=$$$=+=$$$=+=$$$=+=%%%=++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%+++%+%+++$+%%+%%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+%+++%+%+++%+$+++%++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%++%$+%+++$+%+%+%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+$%+%$+%+++%+$++%$++++................................................................................", "+=%%%=+=%%%++=$$$++=$$$=+=%%%++=%%%++=$%%=+=%%%=++$$$=++$$$=+=%%$++=$$$++=$$$=+=$$$=+=$$$=+=%%%=+=%$$=+=%%%++=%%%=++$=$++=$$$=+=$$$=+=$$$=++$%$++=%%%=++$%$+++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%++%$+%+++$+%+++%+%+++%+%+++%+%+++$+%+%+%+%+++%+$+++%+$+%+$+%+++%+%+++%+%+%+%+$%+%$+$+++%+$%++$++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%+++%+%+++$+%+++%+%+++%+%+++%+%+++$+%++%%+%+++%+$+++%+$+%+$+%+++%+%+++%+%%+%%+%+++%+$+++%+%+++$++++................................................................................", "+=$$$=+=%%%++=%%%=+%%%%++=%%%=+%$$$++=%%%=+=$$$=++$$$%+=%%%=+=$$$=+=%%%$+=$$$=+%$$$%+=%%%=+=$$$++=%%%=+=$$$=+=%%%=++$=$++$%%%%++%%%++%$$$%+=$$$%==%%%=+=%%%=++++................................................................................", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................", "................................................................................................................................................................................................................................................", "....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++++++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$+++++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$++$++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++$+++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$+++++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$++$++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++$+++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....++++++++++++++++++++++++++++++++++++++++++++++++++++++.....................................................................................................................................................................................", ".....++++++++++++++++++++++++++++++++++++++++++++++++++++++.....................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "$=%.............................................................................................................................................................................................................................................", "MNO.............................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................"}; wmsysmon-master/src/wmsysmon-master-i386.xpm000066400000000000000000000621001256153655400214470ustar00rootroot00000000000000/* XPM */ static char * wmsysmon_master_xpm[] = { "240 100 80 1", ". c #0000FF", " c None", "+ c #202020", "@ c #000000", "# c #C7C3C7", "$ c #004941", "% c #20B2AE", "& c #107D79", "* c #188A86", "= c #00FF0F", "- c #04FA0F", "; c #09F50F", "> c #0DF10F", ", c #12EC0E", "' c #16E80E", ") c #1BE30E", "! c #1FDF0D", "~ c #24DA0D", "{ c #28D60D", "] c #2DD10D", "^ c #32CC0C", "/ c #36C80C", "( c #3BC30C", "_ c #3FBF0B", ": c #44BA0B", "< c #48B60B", "[ c #4DB10B", "} c #51AD0A", "| c #56A80A", "1 c #5BA30A", "2 c #5F9F09", "3 c #649A09", "4 c #689609", "5 c #6D9109", "6 c #718D08", "7 c #768808", "8 c #7A8408", "9 c #7F7F07", "0 c #847A07", "a c #887607", "b c #8D7107", "c c #916D06", "d c #966806", "e c #9A6406", "f c #9F5F05", "g c #A35B05", "h c #A85605", "i c #AD5105", "j c #B14D04", "k c #B64804", "l c #BA4404", "m c #BF3F03", "n c #C33B03", "o c #C83603", "p c #CC3203", "q c #D12D02", "r c #D62802", "s c #DA2402", "t c #DF1F01", "u c #E31B01", "v c #E81601", "w c #EC1201", "x c #F10D00", "y c #F50900", "z c #FA0400", "A c #FF0000", "B c #007D71", "C c #283C38", "D c #B60418", "E c #00EB00", "F c #0E7973", "G c #F7F3FF", "H c #11817B", "I c #E80426", "J c #71E371", "K c #138984", "L c #16918C", "M c #494949", "N c #7A7A7A", "O c #BCBCBC", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................", "..@###########################################################..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "................................................................+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................", "..@###########################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "................................................................+..+++%%%%+++$$$$&+&%%%%*+&%%%%&+&$$$$&+&%%%%&+&%%%%*+&%%%%&+&%%%%*+&%%%%*++++++................................................................................................", "................................................................+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++&$$$$&++$$$$&+&%%%%&+&%%%%&+&%%%%&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++++++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++%%%%+++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................", "..@###########################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@+++++$$$+++$$$+++$$$++++++++$$$+++$$$+++++++$$$+++$$$+++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@+++++$$$+++$$$+++$$$+++B++++$$$+++$$$+++B+++$$$+++$$$+++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................", "..@++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+...............................................................................................................................................................................", "..@++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@+++++$$$+++$$$+++$$$+++B++++$$$+++$$$+++B+++$$$+++$$$+++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..############################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................", "..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@@@@@@#..+...............................................................................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#....@+CCCC+CCCC+#..+...............................................................................................................................................................................", "..@++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#....@++CC+++CC++#..+...............................................................................................................................................................................", "..@+++++++++++++++++++++++++++++++++++++++++#....@+++++++++++#..+...............................................................................................................................................................................", "..###########################################....#############..+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "................................................................+...............................................................................................................................................................................", "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................", "++%%%+++$$$B+B%%%B+B%%%B+B$$$B+B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+++++++++++++++++++.................................................................................................................................................................", "+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD+..+EE+..+CC+...........FFFF....++++....++++....++++....++++................................................................................................", "+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DGDD..EGEE..CCCC...........HHHH....HHHH....++++....++++....+II+................................................................................................", "+B$$$B++$$$B+B%%%B++%%%B+B%%%B+B%%%B+B%%%B++$$$B+$%%%$+B%%%B++B++++B+++%+++++++..DDDD..EEEE..CCCC...+%$J....KKKK....KKKK....KKKK....++++....+II+................................................................................................", "+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD+..+EE+..+CC+...........LLLL....LLLL....LLLL....LLLL....++++................................................................................................", "+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%++%++++%++%++++++++.................................................................................................................................................................", "++%%%+++$$$%+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++B++++B++%++++++++.................................................................................................................................................................", "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................", "................................................................................................................................................................................................................................................", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................", "+$%%%$+B%%%++B%%%B+B%%%++B%%%B+B%%%B+B%%%B+B$$$B++$$$B++$$$B+B$$$B+B$$$++%$$$%+B%%%++B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+B$$$B+B$$$B+B$$$B+B$$$B+B$$$B+B%%%B++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%+++%+%+++$+%%+%%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+%+++%+%+++%+$+++%++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%++%$+%+++$+%+%+%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+$%+%$+%+++%+$++%$++++................................................................................", "+B%%%B+B%%%++B$$$++B$$$B+B%%%++B%%%++B$%%B+B%%%B++$$$B++$$$B+B%%$++B$$$++B$$$B+B$$$B+B$$$B+B%%%B+B%$$B+B%%%++B%%%B++$B$++B$$$B+B$$$B+B$$$B++$%$++B%%%B++$%$+++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%++%$+%+++$+%+++%+%+++%+%+++%+%+++$+%+%+%+%+++%+$+++%+$+%+$+%+++%+%+++%+%+%+%+$%+%$+$+++%+$%++$++++................................................................................", "+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%+++%+%+++$+%+++%+%+++%+%+++%+%+++$+%++%%+%+++%+$+++%+$+%+$+%+++%+%+++%+%%+%%+%+++%+$+++%+%+++$++++................................................................................", "+B$$$B+B%%%++B%%%B+%%%%++B%%%B+%$$$++B%%%B+B$$$B++$$$%+B%%%B+B$$$B+B%%%$+B$$$B+%$$$%+B%%%B+B$$$++B%%%B+B$$$B+B%%%B++$B$++$%%%%++%%%++%$$$%+B$$$%BB%%%B+B%%%B++++................................................................................", "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................", "................................................................................................................................................................................................................................................", "....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++++++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$+++++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$++$++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++$+++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$+++++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....+$+++$+$+++$+$+++$+$+++$+$+++$++$++$+++$+$+++$+$+++$++.....................................................................................................................................................................................", ".....++$$$+++$$$+++$$$+++$$$+++$$$+++$+++$$$+++$$$+++$$$+++.....................................................................................................................................................................................", ".....++++++++++++++++++++++++++++++++++++++++++++++++++++++.....................................................................................................................................................................................", ".....++++++++++++++++++++++++++++++++++++++++++++++++++++++.....................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "$B%.............................................................................................................................................................................................................................................", "MNO.............................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................", "................................................................................................................................................................................................................................................"}; wmsysmon-master/src/wmsysmon.1000066400000000000000000000021621256153655400170250ustar00rootroot00000000000000.TH wmsysmon 1 "2001-04-09" Debian "System Monitor Dockable Application" .SH NAME wmsysmon \- Windowmaker dock-app for monitoring your system. .SH SYNOPSIS wmsysmon [ \fB-display\fP ] [ \fB-geometry\fP +Xpos+Ypos ] [ \fB-r\fP update rate in ms ] [ \fB-l\fP blinky lights for interrupts ] [ \fB-h\fP print help screen ] [ \fB-v\fP print version number ] .SH DESCRIPTION .B wmsysmon is a dockable application for Windowmaker (and possibly Afterstep). It monitors Memory, Swap, Disk IO, uptime and interrupts. .SH OPTIONS .TP .BI \-display Sets the display where wmsysmon will appear. .TP .BI \-geometry +Xpos+Ypos Set the position for wmsysmon. .TP .BI \-r updateRate Sets the update rate for wmsysmon. .TP .B \-l Set blinky lights on. .TP .B \-h Show the help screen. .TP .B \-v Print wmsysmon's version number. .SH SEE ALSO .BR Website .SH AUTHOR wmsysmon was written by Dave Clark and Vito Caputo . This manual page was written by Luca Bedogni , for the Debian project (but may be used by others). wmsysmon-master/src/wmsysmon.c000066400000000000000000000424571256153655400171220ustar00rootroot00000000000000/* wmsysmon -- system monitoring dockapp Copyright (C) 1998-1999 Dave Clark - clarkd@skynet.ca Copyright (C) 2000 Vito Caputo - swivel@gnugeneration.com wmsysmon 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. wmsysmon 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "wmgeneral.h" #ifdef HI_INTS #include "wmsysmon-master-alpha.xpm" #else #include "wmsysmon-master-i386.xpm" #endif #define WMSYSMON_VERSION "0.7.7" #define CHAR_WIDTH 5 #define CHAR_HEIGHT 7 #define BCHAR_WIDTH 6 #define BCHAR_HEIGHT 9 #define BOFFX (93) #define BOFFY (66) #define BREDX (81) #define BREDY (66) #define BGREENX (87) #define BGREENY (66) #define LITEW (4) #define LITEH (4) #define B_OFF (0) #define B_RED (1) #define B_GREEN (2) /* meter definitions */ #define VBAR_W (4) #define VBAR_H (4) #define INT_LITES (1) #define INT_METERS (2) char wmsysmon_mask_bits[64*64]; int wmsysmon_mask_width = 64; int wmsysmon_mask_height = 64; long start_time = 0; long start_uptime = 0; int counter = 0; int Mem_l; /* line in /proc/meminfo "Mem:" is on */ int Swap_l; /* line in /proc/meminfo "Swap:" is on */ int intr_l; /* line in /proc/stat "intr" is on */ int rio_l; /* line in /proc/stat "disk_rio" is on */ int wio_l; /* line in /proc/stat "disk_wio" is on */ int page_l; /* line in /proc/stat "page" is on */ int swap_l; /* line in /proc/stat "swap" is on */ long io_max; long io_max_diff; int meter[4][2]; #ifdef HI_INTS long _last_ints[24]; long _ints[24]; int int_peaks[24]; #else long _last_ints[16]; long _ints[16]; int int_peaks[16]; #endif long *last_ints; long *ints; long int_mode = INT_METERS; long last_pageins=0; long last_pageouts=0; long last_swapins=0; long last_swapouts=0; char buf[1024]; FILE *statfp; FILE *memfp; int update_rate = 50; char *ProgName; time_t curtime; time_t prevtime; void usage(void); void printversion(void); void BlitString(char *name, int x, int y); void BlitNum(int num, int x, int y); void wmsysmon_routine(int, char **); void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy); void DrawLite(int state, int dx, int dy); void DrawUptime(void); void DrawStuff(void); void DrawMem(void); void DrawMeter(unsigned int, unsigned int, int, int); int main(int argc, char *argv[]) { int i; /* set meter x,y pairs */ meter[3][0] = 108; meter[3][1] = 66; meter[2][0] = 116; meter[2][1] = 66; meter[1][0] = 124; meter[1][1] = 66; meter[0][0] = 132; meter[0][1] = 66; last_ints = _last_ints; ints = _ints; /* Parse Command Line */ ProgName = argv[0]; if (strlen(ProgName) >= 5) ProgName += (strlen(ProgName) - 5); for (i = 1; i < argc; i++) { char *arg = argv[i]; if (*arg == '-') { switch (arg[1]) { case 'd': if (strcmp(arg + 1, "display")) { usage(); exit(1); } break; case 'g': if (strcmp(arg + 1, "geometry")) { usage(); exit(1); } break; case 'v': printversion(); exit(0); break; case 'r': if (argc > (i + 1)) { update_rate = (atoi(argv[i + 1])); i++; } break; case 'l': int_mode = INT_LITES; break; default: usage(); exit(0); break; } } } wmsysmon_routine(argc, argv); return 0; } void wmsysmon_routine(int argc, char **argv) { int i; XEvent Event; FILE *fp; int xfd; struct pollfd pfd; createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height); xfd = openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height); if (xfd < 0) exit(1); pfd.fd = xfd; pfd.events = (POLLIN); /* init ints */ bzero(&_last_ints, sizeof(_last_ints)); bzero(&_ints, sizeof(_ints)); bzero(&int_peaks, sizeof(int_peaks)); /* init uptime */ fp = fopen("/proc/uptime", "r"); if (fp) { if (fscanf(fp, "%ld", &start_time) < 1) fprintf(stderr, "warning: could not read uptime\n"); fclose(fp); start_uptime = time(NULL); } statfp = fopen("/proc/stat", "r"); memfp = fopen("/proc/meminfo", "r"); /* here we find tags in /proc/stat & /proc/meminfo and note their * lines, for faster lookup throughout execution. */ /* /proc/meminfo */ for (i = 0; fgets(buf, 1024, memfp); i++) { if(strstr(buf, "Mem:")) Mem_l = i; else if(strstr(buf, "Swap:")) Swap_l = i; } /* /proc/stat */ for (i = 0; fgets(buf, 1024, statfp); i++) { if (strstr(buf, "disk_wio")) wio_l = i; else if (strstr(buf, "disk_rio")) rio_l = i; else if (strstr(buf, "page")) page_l = i; else if (strstr(buf, "swap")) swap_l = i; else if (strstr(buf, "intr")) intr_l = i; } while (1) { curtime = time(0); DrawUptime(); DrawStuff(); DrawMem(); RedrawWindow(); /* X Events */ poll(&pfd, 1, update_rate); while (XPending(display)) { XNextEvent(display, &Event); switch (Event.type) { case Expose: DirtyWindow(Event.xexpose.x, Event.xexpose.y, Event.xexpose.width, Event.xexpose.height); break; case DestroyNotify: XCloseDisplay(display); exit(0); break; #ifdef MONDEBUG default: printf("got: %i\n", Event.type); #endif break; } } } } void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy) { unsigned int a; /* meters are on a per interruptscale, dictated by the peak, maintain * this peak outside of here, you can use a fixed peak for all ints but * since we're using only 4 lines for our level, the timer interrupt * usually kills the peak for the others so they never move. */ if (peak) { a = level * 3 / peak; } else a = 0; #ifdef MONDEBUG printf("level: %u peak: %u selection: %u\n", level, peak, a); fflush(stdout); #endif if (a > 3) a = 3; copyXPMArea(meter[a][0], meter[a][1], VBAR_W, VBAR_H, dx, dy); } void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy) { int tx = (float)((float)w * ((float)percent / (float)100.0)); copyXPMArea(sx, sy, tx, h, dx, dy); copyXPMArea(sx, sy + h + 1, w - tx, h, dx + tx, dy); } void DrawLite(int state, int dx, int dy) { switch (state) { case B_RED: copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy); break; case B_GREEN: copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy); break; default: case B_OFF: copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy); break; } } void DrawUptime(void) { static int first = 1; static int old_days, old_hours, old_minutes; long uptime; int i; uptime = curtime - start_uptime + start_time; /* blit minutes */ uptime /=60; i = uptime % 60; if (old_minutes != i || first) { old_minutes = i; sprintf(buf, "%02i", i); #ifdef HI_INTS BlitString(buf, 45, 29); #else BlitString(buf, 45, 37); #endif } /* blit hours */ uptime /=60; i = uptime % 24; if (old_hours != i || first) { old_hours = i; sprintf(buf, "%02i", i); #ifdef HI_INTS BlitString(buf, 29, 29); #else BlitString(buf, 29, 37); #endif } /* blit days */ uptime /= 24; i = uptime; if (old_days != i || first) { old_days = i; sprintf(buf, "%03i", i); #ifdef HI_INTS BlitString(buf, 6, 29); #else BlitString(buf, 6, 37); #endif } first = 0; } void DrawStuff( void ) { static int io_last, first = 1; #ifdef HI_INTS static int int_lites[24]; /* to keep track of on/off status */ #else static int int_lites[16]; #endif static int pagein_lite, pageout_lite, swapin_lite, swapout_lite; char *tok; static char seps[] = {" "}; int i, ents; long io; long iodiff; int iopercent; long pageins; long pageouts; long swapins; long swapouts; long intdiff; long *tints; io = iodiff = iopercent = pageins = pageouts = swapins = swapouts = 0; statfp = freopen("/proc/stat", "r", statfp); for (i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) { if (i == rio_l) { tok = strtok(buf, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); ents++; } else if (i == wio_l) { tok = strtok(buf, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); io += atoi(tok); tok = strtok(NULL, seps); ents++; } else if (i == page_l) { sscanf(buf, "%*s %ld %ld", &pageins, &pageouts); ents++; } else if (i == swap_l) { sscanf(buf, "%*s %ld %ld", &swapins, &swapouts); ents++; } else if (i == intr_l) { sscanf( buf, #ifdef HI_INTS "%*s %*d %ld %ld %ld %ld %ld" "%ld %ld %ld %ld %ld %ld %ld" "%ld %ld %ld %ld %ld %ld %ld" "%ld %ld %ld %ld %ld", &ints[0], &ints[1], &ints[2], &ints[3], &ints[4], &ints[5], &ints[6], &ints[7], &ints[8], &ints[9], &ints[10], &ints[11], &ints[12], &ints[13], &ints[14], &ints[15], &ints[16], &ints[17], &ints[18], &ints[19], &ints[20], &ints[21], &ints[22], &ints[23]); #else "%*s %*d %ld %ld %ld %ld %ld" "%ld %ld %ld %ld %ld %ld %ld" "%ld %ld %ld %ld", &ints[0], &ints[1], &ints[2], &ints[3], &ints[4], &ints[5], &ints[6], &ints[7], &ints[8], &ints[9], &ints[10], &ints[11], &ints[12], &ints[13], &ints[14], &ints[15]); #endif ents++; } } /* ------------------ IO bar ------------------ */ if (io_max == 0) io_max = io; if (io > io_max) iodiff = abs(io_max - io); else iodiff = 0; io_max = io; if (io_max_diff !=0) iopercent = ((float) iodiff / (float) io_max_diff) * 100.0; else iopercent = 0; if (iodiff > io_max_diff) io_max_diff = iodiff; if (iopercent > 100) iopercent = 100; if (iopercent != io_last || first) { io_last = iopercent; #ifdef HI_INTS DrawBar(67, 36, 58, 4, iopercent, 3, 20); #else DrawBar(67, 36, 58, 6, iopercent, 3, 26); #endif } if (int_mode == INT_LITES) { /* top 8 ints */ for (i = 0; i < 8; i++) { if (ints[i] > last_ints[i] && !int_lites[i]) { int_lites[i] = 1; #ifdef HI_INTS DrawLite(B_GREEN, 4 + (i * LITEW) + i, 43); #else DrawLite(B_GREEN, 4 + (i * LITEW) + i, 51); #endif } else if (ints[i] == last_ints[i] && int_lites[i]) { int_lites[i] = 0; #ifdef HI_INTS DrawLite(B_OFF, 4 + (i * LITEW) + i, 43); #else DrawLite(B_OFF, 4 + (i * LITEW) + i, 51); #endif } } /* middle/bottom 8 */ for (i = 8; i < 16; i++) { if (ints[i] > last_ints[i] && !int_lites[i]) { int_lites[i] = 1; #ifdef HI_INTS DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 48); #else DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 56); #endif } else if (ints[i] == last_ints[i] && int_lites[i]) { int_lites[i] = 0; #ifdef HI_INTS DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 48); #else DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 56); #endif } } #ifdef HI_INTS /* bottom 8 on alpha/smp x86 */ for (i = 16; i < 24; i++) { if (ints[i] > last_ints[i] && !int_lites[i] ) { int_lites[i] = 1; DrawLite(B_GREEN, 4 + ((i - 16) * LITEW) + (i - 16), 53); } else if (ints[i] == last_ints[i] && int_lites[i]) { int_lites[i] = 0; DrawLite(B_OFF, 4 + ((i -16) * LITEW) + (i - 16), 53); } } #endif } else if (int_mode == INT_METERS) { for (i = 0; i < 8; i++) { if (last_ints[i]) { intdiff = ints[i] - last_ints[i]; int_peaks[i] = (int_peaks[i] + intdiff) >> 1; #ifdef HI_INTS DrawMeter(intdiff, int_peaks[i], VBAR_H + (i * VBAR_W) + i, 43); #else DrawMeter(intdiff, int_peaks[i], VBAR_H + (i * VBAR_W) + i, 51); #endif } } for (i = 8; i < 16; i++) { if (last_ints[i]) { intdiff = ints[i] - last_ints[i]; int_peaks[i] = (int_peaks[i] + intdiff) >> 1; #ifdef HI_INTS DrawMeter(intdiff, int_peaks[i], VBAR_H + ((i - 8) * VBAR_W) + (i - 8), 48); #else DrawMeter(intdiff, int_peaks[i], VBAR_H + ((i - 8) * VBAR_W) + (i - 8), 56); #endif } } #ifdef HI_INTS for (i = 16; i < 24; i++) { if (last_ints[i]) { intdiff = ints[i] - last_ints[i]; int_peaks[i] = (int_peaks[i] + intdiff) >> 1; DrawMeter(intdiff, int_peaks[i], VBAR_H + ((i - 16) * VBAR_W) + (i - 16), 53); } } #endif } tints = last_ints; last_ints = ints; ints = tints; /* page in / out */ if (pageins > last_pageins && !pagein_lite) { pagein_lite = 1; #ifdef HI_INTS DrawLite(B_RED, 51, 43); #else DrawLite(B_RED, 51, 51); #endif } else if (pagein_lite) { pagein_lite = 0; #ifdef HI_INTS DrawLite(B_OFF, 51, 43); #else DrawLite(B_OFF, 51, 51); #endif } if (pageouts > last_pageouts && !pageout_lite) { pageout_lite = 1; #ifdef HI_INTS DrawLite(B_RED, 56, 43); #else DrawLite(B_RED, 56, 51); #endif } else if (pageout_lite) { pageout_lite = 0; #ifdef HI_INTS DrawLite(B_OFF, 56, 43); #else DrawLite(B_OFF, 56, 51); #endif } last_pageins = pageins; last_pageouts = pageouts; /* swap in/out */ if (swapins > last_swapins && !swapin_lite) { swapin_lite = 1; #ifdef HI_INTS DrawLite(B_RED, 51, 48); #else DrawLite(B_RED, 51, 56); #endif } else if (swapin_lite) { swapin_lite = 0; #ifdef HI_INTS DrawLite(B_OFF, 51, 48); #else DrawLite(B_OFF, 51, 56); #endif } if (swapouts > last_swapouts && !swapout_lite) { swapout_lite = 1; #ifdef HI_INTS DrawLite(B_RED, 56, 48); #else DrawLite(B_RED, 56, 56); #endif } else if (swapout_lite) { swapout_lite = 0; #ifdef HI_INTS DrawLite(B_OFF, 56, 48); #else DrawLite(B_OFF, 56, 56); #endif } last_swapins = swapins; last_swapouts = swapouts; first = 0; } void DrawMem(void) { static int last_mem, last_swap, first = 1; long mem_total; long mem_used; long mem_buffers; long mem_cache; long swap_total; long swap_used; long swap_free; int mempercent; int swappercent; int i, ents; counter--; if (counter >= 0) return; /* polling /proc/meminfo is EXPENSIVE */ counter = 3000000 / update_rate; memfp = freopen("/proc/meminfo", "r", memfp); for (i = 0, ents = 0; ents < 2 && fgets(buf, 1024, memfp); i++) { if (i == Mem_l) { sscanf(buf, "%*s %ld %ld %*d %*d %ld %ld", &mem_total, &mem_used, &mem_buffers, &mem_cache); ents++; } else if (i == Swap_l) { sscanf(buf, "%*s %ld %ld %ld", &swap_total, &swap_used, &swap_free); ents++; } } /* could speed this up but we'd lose precision, look more into it to see * if precision change would be noticable, and if speed diff is significant */ mempercent = ((float)(mem_used - mem_buffers - mem_cache) / (float)mem_total) * 100; swappercent = ((float)(swap_used) / (float)swap_total) * 100; if (mempercent != last_mem || first) { last_mem = mempercent; #ifdef HI_INTS DrawBar(67, 36, 58,4 , mempercent, 3, 4); #else DrawBar(67, 36, 58, 6, mempercent, 3, 4); #endif } if (swappercent != last_swap || first) { last_swap = swappercent; #ifdef HI_INTS DrawBar(67, 36, 58, 4, swappercent, 3, 12); #else DrawBar(67, 36, 58, 6, swappercent, 3, 15); #endif } first = 0; } /* Blits a string at given co-ordinates */ void BlitString(char *name, int x, int y) { static int i, c, k; k = x; for (i=0; name[i]; i++) { c = toupper(name[i]); if (c >= 'A' && c <= 'Z') { c -= 'A'; copyXPMArea(c * 6, 74, 6, 8, k, y); k += 6; } else { c -= '0'; copyXPMArea(c * 6, 64, 6, 8, k, y); k += 6; } } } void BlitNum(int num, int x, int y) { sprintf(buf, "%03i", num); BlitString(buf, x, y); } void usage(void) { fprintf(stderr, "\nwmsysmon - http://www.gnugeneration.com\n"); fprintf(stderr, "\n-------------------\n" "|[---------------]| <--- Memory Use %%\n" "|[---------------]| <--- Swap Use %%\n" "|[---------------]| <--- I/O %%\n" "| |\n" "| 000:00:00 | <--- Uptime days:hours:minutes\n" "| |\n" #ifdef HI_INTS "| 01234567 UV | <--- 0-N are hardware interrupts 0-23\n" "| 89ABCDEF WX | <--- U,V are Page IN/OUT, W,X are Swap IN/OUT\n" "| GHIJKLMN YZ |\n" #else "| 01234567 WX | <--- 0-F are hardware interrupts 0-15\n" "| 89ABCDEF YZ | <--- W,X are Page IN/OUT, Y,Z are Swap IN/OUT\n" #endif "-------------------\n"); fprintf(stderr, "usage:\n"); fprintf(stderr, "\t-display \n"); fprintf(stderr, "\t-geometry +XPOS+YPOS\tinitial window position\n"); fprintf(stderr, "\t-r\t\t\tupdate rate in milliseconds (default:300)\n"); fprintf(stderr, "\t-l\t\t\tblinky lights for interrupts vs. meters(default)\n"); fprintf(stderr, "\t-h\t\t\tthis help screen\n"); fprintf(stderr, "\t-v\t\t\tprint the version number\n"); fprintf(stderr, "\n"); } void printversion(void) { fprintf(stderr, "wmsysmon v%s\n", WMSYSMON_VERSION); }