]> code.delx.au - monosys/commitdiff
xfce4-genmon-script: make fields optional
authorJames Bunton <jamesbunton@delx.net.au>
Wed, 31 Aug 2016 11:56:19 +0000 (21:56 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Wed, 31 Aug 2016 11:56:19 +0000 (21:56 +1000)
xfce4-genmon-script.c

index c3c2eec0717b21b24294204bfd0f4220cb042d1f..9ac1360cf5eea89172cedf0624a650d588c19250 100644 (file)
@@ -199,26 +199,37 @@ void print_percent(
     );
 }
 
-int main(void) {
+int main(int argc, char** argv) {
+    char* show_flags = "cmb";
+    if (argc == 2) {
+        show_flags = argv[1];
+    }
+
     printf("<txt>");
 
-    print_percent(
-        "cpu", "%",
-        read_cpu_percent(),
-        50, 100
-    );
+    if (strchr(show_flags, 'c')) {
+        print_percent(
+            "cpu", "%",
+            read_cpu_percent(),
+            50, 100
+        );
+    }
 
-    print_percent(
-        "mem", "%",
-        read_mem_percent(),
-        70, 100
-    );
+    if (strchr(show_flags, 'm')) {
+        print_percent(
+            "mem", "%",
+            read_mem_percent(),
+            70, 100
+        );
+    }
 
-    print_percent(
-        "batt", "%",
-        read_battery_percent(),
-        0, 25
-    );
+    if (strchr(show_flags, 'b')) {
+        print_percent(
+            "batt", "%",
+            read_battery_percent(),
+            0, 25
+        );
+    }
 
     printf("</txt>");