diff -Nru wmsysmon-0.7.8/debian/changelog wmsysmon-0.8.0/debian/changelog --- wmsysmon-0.7.8/debian/changelog 2021-10-18 01:20:22.000000000 +0000 +++ wmsysmon-0.8.0/debian/changelog 2022-08-10 14:05:50.000000000 +0000 @@ -1,3 +1,16 @@ +wmsysmon (0.8.0-1) unstable; urgency=medium + + * New upstream release. + * debian/control + - Bump Standards-Version to 4.6.1. + - Update my email address; now a Debian Developer. + * debian/copyright + - Bump my copyright years and update my email address. + * debian/patches + - Remove all patches; applied upstream. + + -- Doug Torrance Wed, 10 Aug 2022 10:05:50 -0400 + wmsysmon (0.7.8-2) unstable; urgency=medium [ Jeremy Sowden ] diff -Nru wmsysmon-0.7.8/debian/control wmsysmon-0.8.0/debian/control --- wmsysmon-0.7.8/debian/control 2021-10-14 01:44:17.000000000 +0000 +++ wmsysmon-0.8.0/debian/control 2022-08-10 14:05:50.000000000 +0000 @@ -2,7 +2,7 @@ Section: x11 Priority: optional Maintainer: Debian Window Maker Team -Uploaders: Doug Torrance , +Uploaders: Doug Torrance , Jeremy Sowden Build-Depends: debhelper-compat (= 13), libdockapp-dev, @@ -10,7 +10,7 @@ libxext-dev, libxpm-dev, pkg-config -Standards-Version: 4.6.0 +Standards-Version: 4.6.1 Rules-Requires-Root: no Homepage: https://github.com/voyageur/wmsysmon Vcs-Git: https://salsa.debian.org/wmaker-team/wmsysmon.git diff -Nru wmsysmon-0.7.8/debian/copyright wmsysmon-0.8.0/debian/copyright --- wmsysmon-0.7.8/debian/copyright 2021-10-14 01:47:11.000000000 +0000 +++ wmsysmon-0.8.0/debian/copyright 2022-08-10 14:05:50.000000000 +0000 @@ -22,7 +22,7 @@ Files: debian/* Copyright: 1999-2007 Brian E. Ermovick , 2007 Luca Bedogni - 2015-2021 Doug Torrance + 2015-2022 Doug Torrance License: GPL-2+ License: GPL-2+ diff -Nru wmsysmon-0.7.8/debian/patches/0001-Don-t-assume-that-that-variables-from-proc-vmstat-oc.patch wmsysmon-0.8.0/debian/patches/0001-Don-t-assume-that-that-variables-from-proc-vmstat-oc.patch --- wmsysmon-0.7.8/debian/patches/0001-Don-t-assume-that-that-variables-from-proc-vmstat-oc.patch 2021-10-18 00:42:07.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0001-Don-t-assume-that-that-variables-from-proc-vmstat-oc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -From 7529f4042e644baa87b437508b72bece233b437a Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 23 Nov 2019 13:03:46 +0000 -Subject: [PATCH 1/2] Don't assume that that variables from /proc/vmstat occur - in the first 1kB. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/wmsysmon.c | 66 ++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 51 insertions(+), 15 deletions(-) - -diff --git a/src/wmsysmon.c b/src/wmsysmon.c -index cac32f54517c..e89bd00f80d4 100644 ---- a/src/wmsysmon.c -+++ b/src/wmsysmon.c -@@ -512,24 +512,60 @@ void DrawStuff( void ) - - if (kernel_version == NEWER_2_6) - { -- static char *pageins_p=NULL; -- static char *pageouts_p; -- static char *swapins_p; -- static char *swapouts_p; -- -+ char *pageins_p = NULL; -+ char *pageouts_p = NULL; -+ char *swapins_p = NULL; -+ char *swapouts_p = NULL; -+ - vmstatfp = freopen("/proc/vmstat", "r", vmstatfp); -- fread_unlocked (buf, 1024, 1, vmstatfp); -- if (!pageins_p) -+ -+ while(!pageins_p || !pageouts_p || !swapins_p || !swapouts_p) - { -- pageins_p = strstr(buf, "pgpgin" ) + 6; -- pageouts_p = strstr(buf, "pgpgout" ) + 7; -- swapins_p = strstr(buf, "pswpin" ) + 6; -- swapouts_p = strstr(buf, "pswpout" ) + 7; -+ if(fgets(buf, sizeof buf, vmstatfp) == NULL) -+ break; -+ -+#define BUFCMP(s) strncmp(buf, s, sizeof s - 1) -+ -+ if (BUFCMP("pgpgin") == 0) -+ { -+ if (!pageins_p) -+ { -+ pageins_p = buf + sizeof "pgpgin"; -+ sscanf(pageins_p, "%ld", &pageins); -+ } -+ continue; -+ } -+ if (BUFCMP("pgpgout") == 0) -+ { -+ if (!pageouts_p) -+ { -+ pageouts_p = buf + sizeof "pgpgout"; -+ sscanf(pageouts_p, "%ld", &pageouts); -+ } -+ continue; -+ } -+ if (BUFCMP("pswpin") == 0) -+ { -+ if (!swapins_p) -+ { -+ swapins_p = buf + sizeof "pswpin"; -+ sscanf(swapins_p, "%ld", &swapins); -+ } -+ continue; -+ } -+ if (BUFCMP("pswpout") == 0) -+ { -+ if (!swapouts_p) -+ { -+ swapouts_p = buf + sizeof "pswpout"; -+ sscanf(swapouts_p, "%ld", &swapouts); -+ } -+ continue; -+ } -+ -+#undef BUFCMP - } -- sscanf(pageins_p, "%ld", &pageins ); -- sscanf(pageouts_p, "%ld", &pageouts ); -- sscanf(swapins_p, "%ld", &swapins ); -- sscanf(swapouts_p, "%ld", &swapouts ); -+ - } - - for(i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) --- -2.24.0 - diff -Nru wmsysmon-0.7.8/debian/patches/0002-Don-t-assume-that-that-variables-from-proc-meminfo-o.patch wmsysmon-0.8.0/debian/patches/0002-Don-t-assume-that-that-variables-from-proc-meminfo-o.patch --- wmsysmon-0.7.8/debian/patches/0002-Don-t-assume-that-that-variables-from-proc-meminfo-o.patch 2021-10-18 00:43:21.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0002-Don-t-assume-that-that-variables-from-proc-meminfo-o.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -From 5bbdd2233fffc56f0b9b2242ac7a5738f34d55ed Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 23 Nov 2019 13:33:38 +0000 -Subject: [PATCH 2/2] Don't assume that that variables from /proc/meminfo occur - in the first 1kB. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/wmsysmon.c | 118 ++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 88 insertions(+), 30 deletions(-) - -diff --git a/src/wmsysmon.c b/src/wmsysmon.c -index e89bd00f80d4..b658da24daa8 100644 ---- a/src/wmsysmon.c -+++ b/src/wmsysmon.c -@@ -800,19 +800,24 @@ last_swapouts = swapouts; - - void DrawMem(void) - { -- static char *p_mem_tot=NULL, *p_mem_free, *p_mem_buffers, *p_mem_cache; -- static char *p_swap_total, *p_swap_free; -+ char *p_mem_total = NULL; -+ char *p_mem_free = NULL; -+ char *p_mem_buffers = NULL; -+ char *p_mem_cache = NULL; -+ char *p_swap_total = NULL; -+ char *p_swap_free = NULL; - -- static int last_mem = 0, last_swap = 0, first = 1; -- static long mem_total = 0; -- static long mem_free = 0; -- static long mem_buffers = 0; -- static long mem_cache = 0; -- static long swap_total = 0; -- static long swap_free = 0; -+ static int last_mem = 0, last_swap = 0, first = 1; - -- static int mempercent = 0; -- static int swappercent = 0; -+ long mem_total = 0; -+ long mem_free = 0; -+ long mem_buffers = 0; -+ long mem_cache = 0; -+ long swap_total = 0; -+ long swap_free = 0; -+ -+ int mempercent = 0; -+ int swappercent = 0; - - - /* counter--; */ -@@ -821,36 +826,89 @@ void DrawMem(void) - /* counter = 1500 / update_rate; */ - - memfp = freopen("/proc/meminfo", "r", memfp); -- fread_unlocked (buf, 1024, 1, memfp); - -- if (!p_mem_tot) -+ while(!p_mem_total || !p_mem_free || !p_mem_buffers || !p_mem_cache || -+ !p_swap_total || !p_swap_free) - { -- p_mem_tot = strstr(buf, "MemTotal:" ) + 13; -- p_mem_free = strstr(buf, "MemFree:" ) + 13; -- p_mem_buffers = strstr(buf, "Buffers:" ) + 13; -- p_mem_cache = strstr(buf, "Cached:" ) + 13; -- p_swap_total = strstr(buf, "SwapTotal:") + 13; -- p_swap_free = strstr(buf, "SwapFree:" ) + 13; -+ if(fgets(buf, sizeof buf, memfp) == NULL) -+ break; -+ -+#define BUFCMP(s) strncmp(buf, s, sizeof s - 1) -+ -+ if (BUFCMP("MemTotal:") == 0) -+ { -+ if (!p_mem_total) -+ { -+ p_mem_total = buf + sizeof "MemTotal:"; -+ sscanf(p_mem_total, "%ld", &mem_total); -+ } -+ continue; -+ } -+ -+ if (BUFCMP("MemFree:") == 0) -+ { -+ if (!p_mem_free) -+ { -+ p_mem_free = buf + sizeof "MemFree:"; -+ sscanf(p_mem_free, "%ld", &mem_free); -+ } -+ continue; -+ } -+ -+ if (BUFCMP("Buffers:") == 0) -+ { -+ if (!p_mem_buffers) -+ { -+ p_mem_buffers = buf + sizeof "Buffers:"; -+ sscanf(p_mem_buffers, "%ld", &mem_buffers); -+ } -+ continue; -+ } -+ -+ if (BUFCMP("Cached:") == 0) -+ { -+ if (!p_mem_cache) -+ { -+ p_mem_cache = buf + sizeof "Cached:"; -+ sscanf(p_mem_cache, "%ld", &mem_cache); -+ } -+ continue; -+ } -+ -+ if (BUFCMP("SwapTotal:") == 0) -+ { -+ if (!p_swap_total) -+ { -+ p_swap_total = buf + sizeof "SwapTotal:"; -+ sscanf(p_swap_total, "%ld", &swap_total); -+ } -+ continue; -+ } -+ -+ if (BUFCMP("SwapFree:") == 0) -+ { -+ if (!p_swap_free) -+ { -+ p_swap_free = buf + sizeof "SwapFree:"; -+ sscanf(p_swap_free, "%ld", &swap_free); -+ } -+ continue; -+ } -+ -+#undef BUFCMP - } -- -- sscanf(p_mem_tot, "%ld", &mem_total ); -- sscanf(p_mem_free, "%ld", &mem_free ); -- sscanf(p_mem_buffers, "%ld", &mem_buffers); -- sscanf(p_mem_cache, "%ld", &mem_cache ); -- sscanf(p_swap_total, "%ld", &swap_total ); -- sscanf(p_swap_free, "%ld", &swap_free ); - - /* 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_total - mem_free - mem_buffers - mem_cache) -- / -- (float)mem_total) * 100; -+ / -+ (float)mem_total) * 100; - - if (!swap_total) swappercent = 0; - else swappercent = ((float)(swap_total - swap_free) -- / -- (float)swap_total) * 100; -+ / -+ (float)swap_total) * 100; - - if(mempercent != last_mem || first) { - last_mem = mempercent; --- -2.24.0 - diff -Nru wmsysmon-0.7.8/debian/patches/0003-Install-bin-directory-and-do-not-set-owner-and-group.patch wmsysmon-0.8.0/debian/patches/0003-Install-bin-directory-and-do-not-set-owner-and-group.patch --- wmsysmon-0.7.8/debian/patches/0003-Install-bin-directory-and-do-not-set-owner-and-group.patch 2021-10-18 00:43:41.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0003-Install-bin-directory-and-do-not-set-owner-and-group.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -From cd317f60b99d68443b58805cb2d781e4dbf7e81a Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 23 Nov 2019 14:54:02 +0000 -Subject: [PATCH] Install bin directory and do not set owner and group. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/Makefile | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/Makefile b/src/Makefile -index d00f9f1267ab..3249ecc9a4b3 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -18,4 +18,5 @@ clean: - rm -f $(OBJS) $(BIN) - - install: all -- install -g root -o root $(BIN) $(DESTDIR)$(PREFIX)/bin -+ install -d $(DESTDIR)$(PREFIX)/bin -+ install -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin --- -2.24.0 - diff -Nru wmsysmon-0.7.8/debian/patches/0004-Tidy-up-Makefile-a-bit.patch wmsysmon-0.8.0/debian/patches/0004-Tidy-up-Makefile-a-bit.patch --- wmsysmon-0.7.8/debian/patches/0004-Tidy-up-Makefile-a-bit.patch 2021-10-18 00:43:51.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0004-Tidy-up-Makefile-a-bit.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -From f1deb12317a57dd0fe2894553854243dde4829a9 Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 16 May 2020 17:09:02 +0100 -Subject: [PATCH 4/6] Tidy up Makefile a bit. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/Makefile | 22 +++++++++++++--------- - 1 file changed, 13 insertions(+), 9 deletions(-) - -diff --git a/src/Makefile b/src/Makefile -index 3249ecc9a4b3..748b8bea5371 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -1,16 +1,20 @@ --LIBS += -lXpm -lXext -lX11 -lm --#CFLAGS = -g #-DMONDEBUG --CFLAGS += -W -Wall -pedantic -DHI_INTS #undefine HI_INTS if not on x86 SMP or alpha -+# CFLAGS = -g #-DMONDEBUG - --PREFIX = /usr -+# -+# undefine HI_INTS if not on x86 SMP or alpha -+# -+CFLAGS += -W -Wall -pedantic -DHI_INTS -+LIBS += -lXpm -lXext -lX11 -lm - --BIN = wmsysmon --OBJS = wmgeneral.o \ -- wmsysmon.o \ -- cpu_linux.o -+PREFIX = /usr -+ -+BIN = wmsysmon -+OBJS = wmgeneral.o \ -+ wmsysmon.o \ -+ cpu_linux.o - - $(BIN): $(OBJS) -- $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(BIN) -+ $(CC) $(LDFLAGS) $(OBJS) -o $(BIN) $(LIBS) - - all: wmsysmon - --- -2.26.2 - diff -Nru wmsysmon-0.7.8/debian/patches/0005-Use-pkg-config-for-X-dependencies.patch wmsysmon-0.8.0/debian/patches/0005-Use-pkg-config-for-X-dependencies.patch --- wmsysmon-0.7.8/debian/patches/0005-Use-pkg-config-for-X-dependencies.patch 2021-10-18 00:44:08.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0005-Use-pkg-config-for-X-dependencies.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -From e7d66223948340f0657874bcc6a314f6a89994d3 Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 16 May 2020 16:33:25 +0100 -Subject: [PATCH 5/6] Use pkg-config for X dependencies. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/Makefile | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/src/Makefile b/src/Makefile -index 748b8bea5371..8d9db9bec523 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -3,8 +3,15 @@ - # - # undefine HI_INTS if not on x86 SMP or alpha - # --CFLAGS += -W -Wall -pedantic -DHI_INTS --LIBS += -lXpm -lXext -lX11 -lm -+CFLAGS += -W -Wall -pedantic -DHI_INTS \ -+ $(shell pkg-config x11 --cflags) \ -+ $(shell pkg-config xext --cflags) \ -+ $(shell pkg-config xpm --cflags) -+ -+LIBS += $(shell pkg-config x11 --libs) \ -+ $(shell pkg-config xext --libs) \ -+ $(shell pkg-config xpm --libs) \ -+ -lm - - PREFIX = /usr - --- -2.26.2 - diff -Nru wmsysmon-0.7.8/debian/patches/0006-wmgeneral-is-now-available-from-libdockapp.patch wmsysmon-0.8.0/debian/patches/0006-wmgeneral-is-now-available-from-libdockapp.patch --- wmsysmon-0.7.8/debian/patches/0006-wmgeneral-is-now-available-from-libdockapp.patch 2021-10-18 00:44:22.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/0006-wmgeneral-is-now-available-from-libdockapp.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,529 +0,0 @@ -From fd8091dd578553a08ed02235508e4907162e9e29 Mon Sep 17 00:00:00 2001 -From: Jeremy Sowden -Date: Sat, 16 May 2020 17:10:38 +0100 -Subject: [PATCH 6/6] wmgeneral is now available from libdockapp. -Forwarded: https://github.com/voyageur/wmsysmon/pull/2 -Last-Update: 2021-10-17 - ---- - src/Makefile | 7 +- - src/wmgeneral.c | 374 ------------------------------------------------ - src/wmgeneral.h | 62 -------- - src/wmsysmon.c | 14 +- - 4 files changed, 8 insertions(+), 449 deletions(-) - delete mode 100644 src/wmgeneral.c - delete mode 100644 src/wmgeneral.h - ---- a/src/Makefile -+++ b/src/Makefile -@@ -4,11 +4,13 @@ - # undefine HI_INTS if not on x86 SMP or alpha - # - CFLAGS += -W -Wall -pedantic -DHI_INTS \ -+ $(shell pkg-config dockapp --cflags) \ - $(shell pkg-config x11 --cflags) \ - $(shell pkg-config xext --cflags) \ - $(shell pkg-config xpm --cflags) - --LIBS += $(shell pkg-config x11 --libs) \ -+LIBS += $(shell pkg-config dockapp --libs) \ -+ $(shell pkg-config x11 --libs) \ - $(shell pkg-config xext --libs) \ - $(shell pkg-config xpm --libs) \ - -lm -@@ -16,8 +18,7 @@ - PREFIX = /usr - - BIN = wmsysmon --OBJS = wmgeneral.o \ -- wmsysmon.o \ -+OBJS = wmsysmon.o \ - cpu_linux.o - - $(BIN): $(OBJS) ---- a/src/wmgeneral.c -+++ /dev/null -@@ -1,374 +0,0 @@ --#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); -- -- if(wmgen.dirty_w && wmgen.dirty_h) -- 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) { -- static 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; --} ---- a/src/wmgeneral.h -+++ /dev/null -@@ -1,62 +0,0 @@ --#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 *); --void DirtyWindow(int, int, unsigned int, unsigned int); -- --#endif ---- a/src/wmsysmon.c -+++ b/src/wmsysmon.c -@@ -41,9 +41,8 @@ - #include - #include - #include -+#include - -- --#include "wmgeneral.h" - #include "cpu.h" - - #ifdef HI_INTS -@@ -268,16 +267,14 @@ - 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); -+ openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height); - -- pfd.fd = xfd; -+ pfd.fd = XConnectionNumber(display); - pfd.events = (POLLIN); - - /* init ints */ -@@ -330,10 +327,7 @@ - switch (Event.type) - { - case Expose: -- DirtyWindow(Event.xexpose.x, -- Event.xexpose.y, -- Event.xexpose.width, -- Event.xexpose.height); -+ RedrawWindow(); - break; - case DestroyNotify: - XCloseDisplay(display); diff -Nru wmsysmon-0.7.8/debian/patches/series wmsysmon-0.8.0/debian/patches/series --- wmsysmon-0.7.8/debian/patches/series 2021-10-14 01:44:17.000000000 +0000 +++ wmsysmon-0.8.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -0001-Don-t-assume-that-that-variables-from-proc-vmstat-oc.patch -0002-Don-t-assume-that-that-variables-from-proc-meminfo-o.patch -0003-Install-bin-directory-and-do-not-set-owner-and-group.patch -0004-Tidy-up-Makefile-a-bit.patch -0005-Use-pkg-config-for-X-dependencies.patch -0006-wmgeneral-is-now-available-from-libdockapp.patch diff -Nru wmsysmon-0.7.8/README.md wmsysmon-0.8.0/README.md --- wmsysmon-0.7.8/README.md 1970-01-01 00:00:00.000000000 +0000 +++ wmsysmon-0.8.0/README.md 2022-08-09 20:24:11.000000000 +0000 @@ -0,0 +1,16 @@ +# wmsysmon + +wmsysmon is a program designed for use with the Window Maker window manager for the X Window System. It monitors the following system information: Memory usage, swap usage, I/O throughput, system uptime, hardware interrupts, paging and swap activity. + +This is a continuation of code from www.gnugeneration.com (as indicated in original README) +## Dependencies +The dockapp needs the following X.Org libraries: +* libX11 +* libXext +* libXpm + +For common dockapp code, it also needs [libdockapp](https://www.dockapps.net/libdockapp) +## Compilation +Compilation requires the matching devel packages and a C compiler, then run make in src/ directory. + +If you do not have a SMP system (quite rare these days), you can edit the Makefile to remove -DHI_INTS flag diff -Nru wmsysmon-0.7.8/src/Makefile wmsysmon-0.8.0/src/Makefile --- wmsysmon-0.7.8/src/Makefile 2017-12-06 14:00:16.000000000 +0000 +++ wmsysmon-0.8.0/src/Makefile 2022-08-09 20:24:11.000000000 +0000 @@ -1,16 +1,28 @@ -LIBS += -lXpm -lXext -lX11 -lm -#CFLAGS = -g #-DMONDEBUG -CFLAGS += -W -Wall -pedantic -DHI_INTS #undefine HI_INTS if not on x86 SMP or alpha - -PREFIX = /usr - -BIN = wmsysmon -OBJS = wmgeneral.o \ - wmsysmon.o \ - cpu_linux.o +# CFLAGS = -g #-DMONDEBUG + +# +# undefine HI_INTS if not on x86 SMP or alpha +# +CFLAGS += -W -Wall -pedantic -DHI_INTS \ + $(shell pkg-config dockapp --cflags) \ + $(shell pkg-config x11 --cflags) \ + $(shell pkg-config xext --cflags) \ + $(shell pkg-config xpm --cflags) + +LIBS += $(shell pkg-config dockapp --libs) \ + $(shell pkg-config x11 --libs) \ + $(shell pkg-config xext --libs) \ + $(shell pkg-config xpm --libs) \ + -lm + +PREFIX = /usr + +BIN = wmsysmon +OBJS = wmsysmon.o \ + cpu_linux.o $(BIN): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(BIN) + $(CC) $(LDFLAGS) $(OBJS) -o $(BIN) $(LIBS) all: wmsysmon @@ -18,4 +30,5 @@ rm -f $(OBJS) $(BIN) install: all - install -g root -o root $(BIN) $(DESTDIR)$(PREFIX)/bin + install -d $(DESTDIR)$(PREFIX)/bin + install -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin diff -Nru wmsysmon-0.7.8/src/wmgeneral.c wmsysmon-0.8.0/src/wmgeneral.c --- wmsysmon-0.7.8/src/wmgeneral.c 2017-12-06 14:00:16.000000000 +0000 +++ wmsysmon-0.8.0/src/wmgeneral.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,374 +0,0 @@ -#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); - - if(wmgen.dirty_w && wmgen.dirty_h) - 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) { - static 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; -} diff -Nru wmsysmon-0.7.8/src/wmgeneral.h wmsysmon-0.8.0/src/wmgeneral.h --- wmsysmon-0.7.8/src/wmgeneral.h 2017-12-06 14:00:16.000000000 +0000 +++ wmsysmon-0.8.0/src/wmgeneral.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -#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 *); -void DirtyWindow(int, int, unsigned int, unsigned int); - -#endif diff -Nru wmsysmon-0.7.8/src/wmsysmon.c wmsysmon-0.8.0/src/wmsysmon.c --- wmsysmon-0.7.8/src/wmsysmon.c 2017-12-06 14:00:16.000000000 +0000 +++ wmsysmon-0.8.0/src/wmsysmon.c 2022-08-09 20:24:11.000000000 +0000 @@ -41,9 +41,8 @@ #include #include #include +#include - -#include "wmgeneral.h" #include "cpu.h" #ifdef HI_INTS @@ -52,7 +51,7 @@ #include "wmsysmon-master-i386.xpm" #endif -#define WMSYSMON_VERSION "0.7.8" +#define WMSYSMON_VERSION "0.8.0" #define CHAR_WIDTH 5 #define CHAR_HEIGHT 7 @@ -169,14 +168,14 @@ last_ints = _last_ints; ints = _ints; - + /* some defaults for CPU percentage */ cpu_opts.ignore_nice = False; cpu_opts.cpu_number = CPUNUM_NONE; cpu_opts.ignore_procs = 0; - + kernel_version = Get_Kernel_version(); - + /* Parse Command Line */ ProgName = argv[0]; @@ -186,7 +185,7 @@ for (i = 1; i < argc; i++) { char *arg = argv[i]; - + if (*arg == '-') { switch (arg[1]) @@ -242,7 +241,7 @@ cpu_opts.ignore_proc_list[cpu_opts.ignore_procs] = argv[i]; cpu_opts.ignore_procs++; break; - + default: usage(); exit(0); @@ -250,11 +249,11 @@ } } } - + /* Init CPU percentage stuff */ /* NOT NEEDED ON LINUX */ /* cpu_init(); */ - + wmsysmon_routine(argc, argv); @@ -268,16 +267,14 @@ 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; + openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height); + + pfd.fd = XConnectionNumber(display); pfd.events = (POLLIN); /* init ints */ @@ -285,7 +282,7 @@ bzero(&_ints, sizeof(_ints)); bzero(&int_peaks, sizeof(int_peaks)); - + /* init uptime */ fp = fopen("/proc/uptime", "r"); if (fp) { @@ -297,8 +294,8 @@ statfp = fopen("/proc/stat", "r"); memfp = fopen("/proc/meminfo", "r"); if (kernel_version == NEWER_2_6) vmstatfp = fopen("/proc/vmstat", "r"); - - + + /* here we find tags in /proc/stat and note their * lines, for faster lookup throughout execution. */ @@ -311,17 +308,17 @@ } if(strstr(buf, "intr")) intr_l = i; } - + while(1) { curtime = time(0); - + DrawCpuPercentage(); DrawUptime(); DrawStuff(); DrawMem(); RedrawWindow(); - + /* X Events */ poll(&pfd, 1, update_rate); while (XPending(display)) @@ -330,10 +327,7 @@ switch (Event.type) { case Expose: - DirtyWindow(Event.xexpose.x, - Event.xexpose.y, - Event.xexpose.width, - Event.xexpose.height); + RedrawWindow(); break; case DestroyNotify: XCloseDisplay(display); @@ -418,7 +412,7 @@ { int cpupercentage = cpu_get_usage(&cpu_opts); static int oldcpupercentage = -1; - + if (cpupercentage != oldcpupercentage) { #ifdef HI_INTS @@ -438,7 +432,7 @@ static long uptime; static int i; - + uptime = curtime - start_uptime + start_time; /* blit minutes */ @@ -454,7 +448,7 @@ BlitString(buf, 45, 37); #endif } - + /* blit hours */ uptime /=60; i = uptime % 24; @@ -469,7 +463,7 @@ #endif } - + /* blit days */ uptime /= 24; i = uptime; @@ -512,24 +506,59 @@ if (kernel_version == NEWER_2_6) { - static char *pageins_p=NULL; - static char *pageouts_p; - static char *swapins_p; - static char *swapouts_p; - + char *pageins_p = NULL; + char *pageouts_p = NULL; + char *swapins_p = NULL; + char *swapouts_p = NULL; + vmstatfp = freopen("/proc/vmstat", "r", vmstatfp); - fread_unlocked (buf, 1024, 1, vmstatfp); - if (!pageins_p) + + while(!pageins_p || !pageouts_p || !swapins_p || !swapouts_p) { - pageins_p = strstr(buf, "pgpgin" ) + 6; - pageouts_p = strstr(buf, "pgpgout" ) + 7; - swapins_p = strstr(buf, "pswpin" ) + 6; - swapouts_p = strstr(buf, "pswpout" ) + 7; - } - sscanf(pageins_p, "%ld", &pageins ); - sscanf(pageouts_p, "%ld", &pageouts ); - sscanf(swapins_p, "%ld", &swapins ); - sscanf(swapouts_p, "%ld", &swapouts ); + if(fgets(buf, sizeof buf, vmstatfp) == NULL) + break; + +#define BUFCMP(s) strncmp(buf, s, sizeof s - 1) + + if (BUFCMP("pgpgin") == 0) + { + if (!pageins_p) + { + pageins_p = buf + sizeof "pgpgin"; + sscanf(pageins_p, "%ld", &pageins); + } + continue; + } + if (BUFCMP("pgpgout") == 0) + { + if (!pageouts_p) + { + pageouts_p = buf + sizeof "pgpgout"; + sscanf(pageouts_p, "%ld", &pageouts); + } + continue; + } + if (BUFCMP("pswpin") == 0) + { + if (!swapins_p) + { + swapins_p = buf + sizeof "pswpin"; + sscanf(swapins_p, "%ld", &swapins); + } + continue; + } + if (BUFCMP("pswpout") == 0) + { + if (!swapouts_p) + { + swapouts_p = buf + sizeof "pswpout"; + sscanf(swapouts_p, "%ld", &swapouts); + } + continue; + } + +#undef BUFCMP + } } for(i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) @@ -551,20 +580,20 @@ { 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]); + "%*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" + "%*s %*d %ld %ld %ld %ld %ld" "%ld %ld %ld %ld %ld %ld %ld" "%ld %ld %ld %ld", &ints[0], &ints[1], &ints[2], @@ -574,247 +603,305 @@ &ints[12], &ints[13], &ints[14], &ints[15]); #endif - ents++; + ents++; + } } -} - -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; + 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); + DrawLite(B_GREEN, 4 + (i * LITEW) + i, 43); #else - DrawLite(B_GREEN, 4 + (i * LITEW) + i, 51); + DrawLite(B_GREEN, 4 + (i * LITEW) + i, 51); #endif - } else if(ints[i] == last_ints[i] && int_lites[i]) { - int_lites[i] = 0; + } 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); + DrawLite(B_OFF, 4 + (i * LITEW) + i, 43); #else - DrawLite(B_OFF, 4 + (i * LITEW) + i, 51); + 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; + /* 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); + DrawLite(B_GREEN, 4 + ((i - 8) * LITEW) + (i - 8), 48); #else - DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 56); + 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; + } 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); + DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 48); #else - DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 56); + 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); + /* 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); + } 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); + 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); + 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; + tints = last_ints; + last_ints = ints; + ints = tints; -/* page in / out */ + /* page in / out */ -if (pageins > last_pageins && !pagein_lite) { - pagein_lite = 1; + if (pageins > last_pageins && !pagein_lite) { + pagein_lite = 1; #ifdef HI_INTS - DrawLite(B_RED, 51, 43); + DrawLite(B_RED, 51, 43); #else - DrawLite(B_RED, 51, 51); + DrawLite(B_RED, 51, 51); #endif -} else if(pagein_lite) { - pagein_lite = 0; + } else if(pagein_lite) { + pagein_lite = 0; #ifdef HI_INTS - DrawLite(B_OFF, 51, 43); + DrawLite(B_OFF, 51, 43); #else - DrawLite(B_OFF, 51, 51); + DrawLite(B_OFF, 51, 51); #endif -} + } -if (pageouts > last_pageouts && !pageout_lite) { - pageout_lite = 1; + if (pageouts > last_pageouts && !pageout_lite) { + pageout_lite = 1; #ifdef HI_INTS - DrawLite(B_RED, 56, 43); + DrawLite(B_RED, 56, 43); #else - DrawLite(B_RED, 56, 51); + DrawLite(B_RED, 56, 51); #endif -} else if(pageout_lite) { - pageout_lite = 0; + } else if(pageout_lite) { + pageout_lite = 0; #ifdef HI_INTS - DrawLite(B_OFF, 56, 43); + DrawLite(B_OFF, 56, 43); #else - DrawLite(B_OFF, 56, 51); + DrawLite(B_OFF, 56, 51); #endif -} + } -last_pageins = pageins; -last_pageouts = pageouts; + last_pageins = pageins; + last_pageouts = pageouts; -/* swap in/out */ + /* swap in/out */ -if(swapins > last_swapins && !swapin_lite) { - swapin_lite = 1; + if(swapins > last_swapins && !swapin_lite) { + swapin_lite = 1; #ifdef HI_INTS - DrawLite(B_RED, 51, 48); + DrawLite(B_RED, 51, 48); #else - DrawLite(B_RED, 51, 56); + DrawLite(B_RED, 51, 56); #endif -} else if(swapin_lite) { - swapin_lite = 0; + } else if(swapin_lite) { + swapin_lite = 0; #ifdef HI_INTS - DrawLite(B_OFF, 51, 48); + DrawLite(B_OFF, 51, 48); #else - DrawLite(B_OFF, 51, 56); + DrawLite(B_OFF, 51, 56); #endif -} + } -if (swapouts > last_swapouts && !swapout_lite) { - swapout_lite = 1; + if (swapouts > last_swapouts && !swapout_lite) { + swapout_lite = 1; #ifdef HI_INTS - DrawLite(B_RED, 56, 48); + DrawLite(B_RED, 56, 48); #else - DrawLite(B_RED, 56, 56); + DrawLite(B_RED, 56, 56); #endif -} else if(swapout_lite) { - swapout_lite = 0; + } else if(swapout_lite) { + swapout_lite = 0; #ifdef HI_INTS - DrawLite(B_OFF, 56, 48); + DrawLite(B_OFF, 56, 48); #else - DrawLite(B_OFF, 56, 56); + DrawLite(B_OFF, 56, 56); #endif -} + } -last_swapins = swapins; -last_swapouts = swapouts; + last_swapins = swapins; + last_swapouts = swapouts; } void DrawMem(void) { - static char *p_mem_tot=NULL, *p_mem_free, *p_mem_buffers, *p_mem_cache; - static char *p_swap_total, *p_swap_free; - - static int last_mem = 0, last_swap = 0, first = 1; - static long mem_total = 0; - static long mem_free = 0; - static long mem_buffers = 0; - static long mem_cache = 0; - static long swap_total = 0; - static long swap_free = 0; - - static int mempercent = 0; - static int swappercent = 0; + char *p_mem_total = NULL; + char *p_mem_free = NULL; + char *p_mem_buffers = NULL; + char *p_mem_cache = NULL; + char *p_swap_total = NULL; + char *p_swap_free = NULL; + + static int last_mem = 0, last_swap = 0, first = 1; + + long mem_total = 0; + long mem_free = 0; + long mem_buffers = 0; + long mem_cache = 0; + long swap_total = 0; + long swap_free = 0; + int mempercent = 0; + int swappercent = 0; -/* counter--; */ +#if 0 + counter--; -/* if(counter >= 0) return; /\* polling /proc/meminfo is EXPENSIVE *\/ */ -/* counter = 1500 / update_rate; */ + if(counter >= 0) return; /* polling /proc/meminfo is EXPENSIVE */ + counter = 1500 / update_rate; +#endif memfp = freopen("/proc/meminfo", "r", memfp); - fread_unlocked (buf, 1024, 1, memfp); - if (!p_mem_tot) + while(!p_mem_total || !p_mem_free || !p_mem_buffers || !p_mem_cache || + !p_swap_total || !p_swap_free) { - p_mem_tot = strstr(buf, "MemTotal:" ) + 13; - p_mem_free = strstr(buf, "MemFree:" ) + 13; - p_mem_buffers = strstr(buf, "Buffers:" ) + 13; - p_mem_cache = strstr(buf, "Cached:" ) + 13; - p_swap_total = strstr(buf, "SwapTotal:") + 13; - p_swap_free = strstr(buf, "SwapFree:" ) + 13; - } - - sscanf(p_mem_tot, "%ld", &mem_total ); - sscanf(p_mem_free, "%ld", &mem_free ); - sscanf(p_mem_buffers, "%ld", &mem_buffers); - sscanf(p_mem_cache, "%ld", &mem_cache ); - sscanf(p_swap_total, "%ld", &swap_total ); - sscanf(p_swap_free, "%ld", &swap_free ); + if(fgets(buf, sizeof buf, memfp) == NULL) + break; + +#define BUFCMP(s) strncmp(buf, s, sizeof s - 1) + + if (BUFCMP("MemTotal:") == 0) + { + if (!p_mem_total) + { + p_mem_total = buf + sizeof "MemTotal:"; + sscanf(p_mem_total, "%ld", &mem_total); + } + continue; + } + + if (BUFCMP("MemFree:") == 0) + { + if (!p_mem_free) + { + p_mem_free = buf + sizeof "MemFree:"; + sscanf(p_mem_free, "%ld", &mem_free); + } + continue; + } + + if (BUFCMP("Buffers:") == 0) + { + if (!p_mem_buffers) + { + p_mem_buffers = buf + sizeof "Buffers:"; + sscanf(p_mem_buffers, "%ld", &mem_buffers); + } + continue; + } + + if (BUFCMP("Cached:") == 0) + { + if (!p_mem_cache) + { + p_mem_cache = buf + sizeof "Cached:"; + sscanf(p_mem_cache, "%ld", &mem_cache); + } + continue; + } + + if (BUFCMP("SwapTotal:") == 0) + { + if (!p_swap_total) + { + p_swap_total = buf + sizeof "SwapTotal:"; + sscanf(p_swap_total, "%ld", &swap_total); + } + continue; + } + + if (BUFCMP("SwapFree:") == 0) + { + if (!p_swap_free) + { + p_swap_free = buf + sizeof "SwapFree:"; + sscanf(p_swap_free, "%ld", &swap_free); + } + continue; + } + +#undef BUFCMP + } /* 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_total - mem_free - mem_buffers - mem_cache) - / - (float)mem_total) * 100; + / + (float)mem_total) * 100; if (!swap_total) swappercent = 0; else swappercent = ((float)(swap_total - swap_free) - / - (float)swap_total) * 100; + / + (float)swap_total) * 100; if(mempercent != last_mem || first) { last_mem = mempercent; @@ -847,7 +934,7 @@ k = x; for (i=0; name[i]; i++) { - c = toupper(name[i]); + c = toupper(name[i]); if (c >= 'A' && c <= 'Z') { c -= 'A'; copyXPMArea(c * 6, 74, 6, 8, k, y); @@ -874,7 +961,7 @@ BlitString(buf, newx, y); } - + void usage(void) {