Workaround for Linux 3.14
[sysstatus.git] / src / status / memusage.c
index f69c0274b747e7749c0efdd043e8c048ccfeb5fd..15523de20008e1e42c3d93b9a682ef355457ac25 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "common.h"
 #include "tools.h"
@@ -33,6 +34,9 @@ void status_memusage(GlobalData *g)
     memfree = atoi(&stline[17]);
 
     stlen = getline(&stline, &stlen, stfile);
+    if (stlen > 13 && !memcmp(stline, "MemAvailable:", 13)) {
+      stlen = getline(&stline, &stlen, stfile);
+    }
     membuffers = atoi(&stline[17]);
 
     stlen = getline(&stline, &stlen, stfile);
@@ -47,9 +51,9 @@ void status_memusage(GlobalData *g)
 
     /* Change color based on % of RAM used */
     if ((float)memused / (float)memtotal < 0.85) {
-      s.color = "green";
+      s.color = "#22FF22";  // green
     } else {
-      s.color = "red";
+      s.color = "#FF0000";  // red
     }
 
     snprintf(text, sizeof(text), "Mem: %d M", memused);