Change named colors to hex values
[sysstatus.git] / src / status / memusage.c
index 6a6cb21441923529851da25a67df433e11e3511a..6e715145aa6940a91e98db092505ce379fb96898 100644 (file)
@@ -1,12 +1,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "status/memusage.h"
+#include "common.h"
 #include "tools.h"
 
 
-void status_memusage()
+void status_memusage(GlobalData *g)
 {
+  StatusItem s;
+  char text[16] = { 0 };
+
   char *stline = NULL;
   size_t stlen;
   FILE *stfile;
@@ -18,6 +21,9 @@ void status_memusage()
   int memcached = 0;
 
 
+  statusitem_init(&s);
+  s.text = text;
+
   stfile = fopen("/proc/meminfo", "r");
   if (stfile != NULL) {
     stlen = getline(&stline, &stlen, stfile);
@@ -41,11 +47,13 @@ void status_memusage()
 
     /* Change color based on % of RAM used */
     if ((float)memused / (float)memtotal < 0.85) {
-      fputs("^fg(green)", stdout);
+      s.color = "#22FF22";  // green
     } else {
-      fputs("^fg(red)", stdout);
+      s.color = "#FF0000";  // red
     }
 
-    printf(" Mem: %d M ", memused);
+    snprintf(text, sizeof(text), "Mem: %d M", memused);
+
+    line_append_item(g, &s);
   }
 }