diff -ru bfm-0.6.0/ChangeLog bfm-0.6.1/ChangeLog
--- bfm-0.6.0/ChangeLog	2003-10-11 09:36:45.000000000 +0100
+++ bfm-0.6.1/ChangeLog	2003-11-01 16:46:25.000000000 +0000
@@ -12,3 +12,13 @@
 		gkrellm.
 	* : Bumped revision to 0.6.0 from the original 0.5.1 release on
 		http://pigeond.net/bfm/.
+
+2003-11-02 16:37  James Rowe  <Jay@jnrowe.uklinux.net>
+	* : Applied patch from Huw Giddens to fix the memory usage routines
+		for 2.6 kernels that still works for 2.4 kernels.  It is now
+		possible to use the same binary with different kernels.
+	* : Import of debian packaging dir, again from Huw Giddens.  Probably
+		requires some fixing by someone with a Debian box, because 
+		some of the Makefile changes have not been applied. [ PREFIX
+		and "all" target].  And the "install" target changes have been
+		taken under some duress.
diff -ru bfm-0.6.0/Makefile bfm-0.6.1/Makefile
--- bfm-0.6.0/Makefile	2003-10-11 09:36:01.000000000 +0100
+++ bfm-0.6.1/Makefile	2003-11-01 16:45:41.000000000 +0000
@@ -14,7 +14,7 @@
 # EXTRA += -DKDE_DOCKAPP
 
 # where to install this program
-PREFIX = /usr/local
+PREFIX ?= /usr/local
 
 # no user serviceable parts below
 EXTRA += $(WMAN)
@@ -134,6 +134,7 @@
 clean:
 	rm -f bubblefishymon *.o *.bb* *.gcov gmon.* *.da *~ *.so
 
-install:
-	install $(INSTALL) $(BUBBLEFISHYMON) $(DESTDIR)$(PREFIX)/bin
-	install $(INSTALL_MAN) doc/bubblefishymon.1 $(DESTDIR)$(PREFIX)/man/man1
+install: 
+	install -d $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
+	install $(INSTALL) $(BUBBLEFISHYMON) $(DESTDIR)/$(PREFIX)/bin
+	install $(INSTALL_MAN) doc/bubblefishymon.1 $(DESTDIR)/$(PREFIX)/share/man/man1
diff -ru bfm-0.6.0/bubblemon.c bfm-0.6.1/bubblemon.c
--- bfm-0.6.0/bubblemon.c	2003-10-11 09:29:08.000000000 +0100
+++ bfm-0.6.1/bubblemon.c	2003-11-01 16:44:06.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * bubblefishymon 0.6.0
+ * bubblefishymon 0.6.1
  *
  * Well, Hacks from bubblemon by timecop and Johan
  *
@@ -76,7 +76,7 @@
  */
 #define _GNU_SOURCE
 
-#define VERSION "0.6.0"
+#define VERSION "0.6.1"
 
 /* general includes */
 #include <stdio.h>
diff -ru bfm-0.6.0/fishmon.c bfm-0.6.1/fishmon.c
--- bfm-0.6.0/fishmon.c	2001-11-27 11:11:09.000000000 +0000
+++ bfm-0.6.1/fishmon.c	2003-11-01 16:43:34.000000000 +0000
@@ -1,3 +1,23 @@
+/*  BubbleFishyMon dockapp 0.6.1
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+/* Huw Giddens 2003-10-28: Added missing copyright boilerplate. Corrected the
+ *     calculation that keeps the fish in the water, and put it in its own
+ *     function adjust_y().
+ */
 #define _GNU_SOURCE
 #define VERSION "1.23"
 
@@ -50,7 +70,6 @@
 
 /* global variables */
 extern BubbleMonData bm;
-extern int real_waterlevel_max;
 extern int fish_traffic;
 extern int time_enabled;
 
@@ -226,10 +245,23 @@
     }
 }
 
+/* This function adjusts a passed y value so that it's not less than the 
+ * water level. 0 on the y axis is at the top of the frame. This is called by
+ * fish_update() and traffic_fish_update(). It returns the corrected value.
+ */
+static int adjust_y(int y)
+{
+	// Pigeon
+	// Make sure the fish is in the water :)
+	int min_y = (YMAX * (100 - bm.mem_percent))/100;
+
+	if(y <= min_y) return min_y;
+	else return y;
+}
+
 void fish_update(void)
 {
     int i, j;
-    int min_y;
 
     for (i = 0; i < NRFISH; i++) {
 
@@ -283,14 +315,7 @@
 	    bm.fishes[i].y++;
 	}
 
-	// Pigeon
-	// Make sure the fish is in the water :)
-	min_y = real_waterlevel_max + 3;
-
-	if(bm.fishes[i].y <= min_y)
-	{
-	    bm.fishes[i].y = min_y;
-	}
+	bm.fishes[i].y = adjust_y(bm.fishes[i].y);
 
 	/* handle fish currently turning around */
 	if (bm.fishes[i].turn) {
@@ -613,7 +638,6 @@
 void traffic_fish_update()
 {
     int i, j;
-    int min_y;
 
 	int rx_speed = net_rx_speed();
 	int tx_speed = net_tx_speed();
@@ -696,14 +720,7 @@
 			bm.fishes[i].y++;
 		}
 
-		// Pigeon
-		// Make sure the fish is in the water :)
-		min_y = real_waterlevel_max + 3;
-
-		if(bm.fishes[i].y <= min_y)
-		{
-			bm.fishes[i].y = min_y;
-		}
+		bm.fishes[i].y = adjust_y(bm.fishes[i].y);
 
 		/* animate fishes using fish_animation array */
 		draw_sprite(bm.fishes[i].tx, bm.fishes[i].y,
diff -ru bfm-0.6.0/gkrellm-bfm.c bfm-0.6.1/gkrellm-bfm.c
--- bfm-0.6.0/gkrellm-bfm.c	2003-10-11 09:29:08.000000000 +0100
+++ bfm-0.6.1/gkrellm-bfm.c	2003-11-01 16:44:15.000000000 +0000
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <time.h>
 
-#define PLUGIN_VERSION	"0.6.0"
+#define PLUGIN_VERSION	"0.6.1"
 
 #define PLUGIN_NAME	"gkrellm-bfm"
 #define PLUGIN_DESC	"bubblefishymon gkrellm port"
diff -ru bfm-0.6.0/sys_linux.c bfm-0.6.1/sys_linux.c
--- bfm-0.6.0/sys_linux.c	2003-10-11 09:29:08.000000000 +0100
+++ bfm-0.6.1/sys_linux.c	2003-11-01 16:34:58.000000000 +0000
@@ -16,17 +16,17 @@
  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
  *
  */
+/* Huw Giddens 2003-10-27: Changed system_memory() so that it reports memory
+ *     correctly on Linux 2.6 systems. Also works on 2.4 systems without
+ *     recompile. Based on a patch by Marcelo E Magallon <mmagallo@debian.org>,
+ *     see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=175140
+ */
 
 #include <stdio.h>
 #include <string.h>
-#include <linux/version.h>
 #include "include/bubblemon.h"
 #include "include/sys_include.h"
 
-#if LINUX_VERSION_CODE > 0x20514
-#define  KERNEL_26
-#endif
-
 extern BubbleMonData bm;
 
 /* returns current CPU load in percent, 0 to 100 */
@@ -76,92 +76,50 @@
 
 int system_memory(void)
 {
-    u_int64_t my_mem_used, my_mem_max;
-    u_int64_t my_swap_used, my_swap_max;
-#ifdef KERNEL_26
-    char *p;
-#endif
-
-    static int mem_delay = 0;
-    FILE *mem;
-    static u_int64_t aa, ab, ac, ad;
-#ifndef KERNEL_26
-    static u_int64_t ae, af, ag, ah;
-#endif
-    /* put this in permanent storage instead of stack */
-    static char shit[2048];
+	u_int64_t mem_used, mem_max, swap_used, swap_max;
+	u_int64_t value, mem_cache, mem_buffers, swap_cache;
+	static int delay = 0;
+	FILE *mem;
+	char name[256];
+	char line[256];
+
+	if (delay-- <= 0) {
+		mem = fopen("/proc/meminfo", "r"); 
+		if (mem == NULL) return 0;
+		while (!feof(mem)) {
+			if (fgets(line, 256, mem) == NULL) break;
+			if (sscanf(line, "%s %Ld", name, &value) != 2) continue;
+
+			/* Before I calculate mem_used, I store MemFree in the mem_used
+			 * variable. The same with swap_used/SwapFree */
+			if (strcmp(name, "MemTotal:") == 0) mem_max = value;
+		    else if (strcmp(name, "Cached:") == 0) mem_cache = value;
+		    else if (strcmp(name, "Buffers:") == 0) mem_buffers = value;
+		    else if (strcmp(name, "MemFree:") == 0) mem_used = value;
+		    else if (strcmp(name, "SwapTotal:") == 0) swap_max = value;
+		    else if (strcmp(name, "SwapFree:") == 0) swap_used = value;
+		    else if (strcmp(name, "SwapCached:") == 0) swap_cache = value;
+		}
+		fclose(mem);
 
-    /* we might as well get both swap and memory at the same time.
-     * sure beats opening the same file twice */
-    if (mem_delay-- <= 0) {
-#ifdef KERNEL_26
-	mem = fopen("/proc/meminfo", "r");
-	memset(shit, 0, sizeof(shit));
-	fread(shit, 2048, 1, mem);
-	p = strstr(shit, "MemTotal");
-	if (p) {
-	    sscanf(p, "MemTotal:%Ld", &aa);
-	    my_mem_max = aa << 10;
-
-	    p = strstr(p, "Active");
-	    if (p) {
-		sscanf(p, "Active:%Ld", &ab);
-		my_mem_used = ab << 10;
-
-		p = strstr(p, "SwapTotal");
-		if (p) {
-		    sscanf(p, "SwapTotal:%Ld", &ac);
-		    my_swap_max = ac << 10;
-
-		    p = strstr(p, "SwapFree");
-		    if (p) {
-			sscanf(p, "SwapFree:%Ld", &ad);
-			my_swap_used = my_swap_max - (ad << 10);
-
-			bm.mem_used = my_mem_used;
-			bm.mem_max = my_mem_max;
-			bm.swap_used = my_swap_used;
-			bm.swap_max = my_swap_max;
-		    }
+		mem_used = (mem_max - mem_used) + (swap_max - swap_used) -
+			(mem_cache + mem_buffers + swap_cache);
+		if (mem_used > mem_max) {
+			swap_used = mem_used - mem_max;
+			mem_used = mem_max;
+		} else {
+			swap_used = 0;
 		}
-	    }
-	}
-	fclose(mem);
-	mem_delay = 25;
-#else
-	mem = fopen("/proc/meminfo", "r");
-	fgets(shit, 2048, mem);
-	
-	fscanf(mem, "%*s %Ld %Ld %Ld %Ld %Ld %Ld", &aa, &ab, &ac,
-	       &ad, &ae, &af);
-	fscanf(mem, "%*s %Ld %Ld", &ag, &ah);
-	fclose(mem);
-	mem_delay = 25;
-
-	/* calculate it */
-	my_mem_max = aa;	/* memory.total; */
-	my_swap_max = ag;	/* swap.total; */
-
-	my_mem_used = ah + ab - af - ae;	/* swap.used + memory.used - memory.cached - memory.buffer; */
-
-	if (my_mem_used > my_mem_max) {
-	    my_swap_used = my_mem_used - my_mem_max;
-	    my_mem_used = my_mem_max;
-	} else {
-	    my_swap_used = 0;
-	}
 
-	bm.mem_used = my_mem_used;
-	bm.mem_max = my_mem_max;
-	bm.swap_used = my_swap_used;
-	bm.swap_max = my_swap_max;
-#endif
+		/* proc reports usage in kb, bm wants it in bytes. */
+		bm.mem_used  = 1024 * mem_used;
+		bm.mem_max   = 1024 * mem_max;
+		bm.swap_used = 1024 * swap_used;
+		bm.swap_max  = 1024 * swap_max;
 
-	/* memory info changed - update things */
-	return 1;
-    }
-    /* nothing new */
-    return 0;
+		return 1; /* update */
+	}
+	return 0; /* nothing changed, don't update */
 }
 
 #ifdef ENABLE_MEMSCREEN
