--- gmemusage-0.2.orig/gmemusage.c
+++ gmemusage-0.2/gmemusage.c
@@ -40,6 +40,9 @@
 
 #define TOO_SMALL	0
 #define	BIG_ENOUGH	1
+
+#define name_length 64
+
 /*
  * I hate these file-wide variables, but since draw_window is going to be
  * called from a signal, we can't pass it any args.
@@ -108,9 +111,10 @@
       border_width = 4 ,
       display_width ,
       display_height ;
-   char
-      *window_name = "gmemusage" ,
-      *icon_name = "gmemusage" ;
+   char 
+     window_name [name_length];
+   char 
+     * window_name_list [1];
    Pixmap
       icon_pixmap ;
    XSizeHints
@@ -141,6 +145,11 @@
    {
       strcpy ( progname , argv [0] ) ;
    }
+
+   strcpy(window_name, "gmemusage: ");
+   gethostname (&window_name[11], name_length - 11); 
+   window_name_list[0] = window_name;
+
 /*
  * Allocate necessaru X structures for later use. Apparently this needs to
  * be done before any other X stuff.
@@ -228,13 +237,14 @@
    size_hints -> flags = PPosition | PSize | PMinSize ;
    size_hints -> min_width = default_width ;
    size_hints -> min_height = default_height ;
-   if ( XStringListToTextProperty (&window_name , 1 , &windowName ) == 0 )
+   
+   if ( XStringListToTextProperty ( window_name_list , 1 , &windowName ) == 0 )
    {
       fprintf ( stderr , "%s: struct allocation for windowName failed\n" ,
 		progname ) ;
       exit ( 1 ) ;
    }
-   if ( XStringListToTextProperty ( &icon_name , 1 , &iconName ) == 0 )
+   if ( XStringListToTextProperty ( window_name_list , 1 , &iconName ) == 0 )
    {
       fprintf ( stderr , "%s: struct allocation for iconName failed\n" ,
 		progname ) ;
@@ -752,7 +762,7 @@
    valuemask |= GCPlaneMask;
    values.plane_mask = AllPlanes;
    blackGC = XCreateGC ( display , win , valuemask , &values ) ;
-   XSetForeground ( display , blackGC , BlackPixel ( display , screen_num ) ) ;
+   XSetForeground ( display , blackGC , Background . pixel ) ;
    return ;
 }
 #if 0
--- gmemusage-0.2.orig/proc.c
+++ gmemusage-0.2/proc.c
@@ -7,6 +7,7 @@
  * See file COPYING (included in this distribution) for copyright information.
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <dirent.h>
@@ -23,6 +23,9 @@
 /*
  * Set values for various memory usages
  */
+#define MemTotalLine   "MemTotal:"
+#define        MemFreeLine     "MemFree:"
+#define        BuffersLine     "Buffers:"
 static void
 SetMemInfo ( void )
 {
@@ -63,12 +66,28 @@
    {
       if ( !strncmp ( buf , MemLine , MemLineLen ) )
       {
+	 /* Linux 2.4 (and earlier?) */
 	 /* Mem: total used free shared buffers cached */
 	 sscanf ( buf , "%*s %d %*d %d %*d %d" , &totalmem , &freemem ,
 		  &buffermem ) ;
 	 break ;
+	 
+       /* Linux 2.6 (and later?) */
+       } else if (!strncmp(buf, MemTotalLine, strlen(MemTotalLine))) {
+	      sscanf(buf, "%*s %d", &totalmem);
+       } else if (!strncmp(buf, MemFreeLine, strlen(MemFreeLine))) {
+	      sscanf(buf, "%*s %d", &freemem);
+       } else if (!strncmp(buf, BuffersLine, strlen(BuffersLine))) {
+	      sscanf(buf, "%*s %d", &buffermem);
       }
    }
+   
+   if (!totalmem) {
+	 fprintf(stderr, "Fatal error reading /proc/meminfo\n");
+	 exit(1);
+   }
+   
+   sysmem /= 1024 ;
    sysmem /= 1024 ;
    totalmem /= 1024 ;
    freemem /= 1024 ;
