]> git.sur5r.net Git - i3/i3status/blobdiff - src/config.c
Add debian changelog entry to keep updates from overwriting local versions
[i3/i3status] / src / config.c
index da1e5d198538aea34ff3da8ba35c7717ceec3b5d..e39c19b66d3c5bfca96e7b71eb273a03e2133737 100644 (file)
@@ -1,11 +1,15 @@
+// vim:ts=8:expandtab
 #include <sys/stat.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include <glob.h>
 
 #include "i3status.h"
 
+int highest_order = 0;
+
 /*
  * Reads the configuration from the given file
  *
@@ -66,20 +70,18 @@ int load_configuration(const char *configfile) {
                         get_ethspeed = true;
                 OPT("get_cpu_temperature") {
                         get_cpu_temperature = true;
-                        if (strlen(dest_value) > 0) {
-                                if (asprintf(&thermal_zone, "/sys/class/thermal/thermal_zone%d/temp", atoi(dest_value)) == -1)
-                                        die("Could not build thermal_zone path\n");
-                        } else {
-                                 if (asprintf(&thermal_zone, "/sys/class/thermal/thermal_zone0/temp") == -1)
-                                        die("Could not build thermal_zone path\n");
-                        }
+                        int zone = 0;
+                        if (strlen(dest_value) > 0)
+                            zone = atoi(dest_value);
+                        if (asprintf(&thermal_zone, THERMAL_ZONE, zone) == -1)
+                            die("Could not build thermal_zone path\n");
                 } OPT("normcolors")
                         wmii_normcolors = strdup(dest_value);
                 OPT("interval")
                         interval = atoi(dest_value);
                 OPT("wmii_path")
                 {
-#ifndef DZEN
+#if !defined(DZEN) && !defined(XMOBAR)
                         static glob_t globbuf;
                         struct stat stbuf;
                         if (glob(dest_value, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
@@ -110,9 +112,12 @@ int load_configuration(const char *configfile) {
                 }
                 OPT("order")
                 {
-                        #define SET_ORDER(opt, idx) { if (strcasecmp(token, opt) == 0) order[idx] = c++; }
+
+                        for (int c = 0; c < MAX_ORDER; c++)
+                                order[c] = -1;
+
+                        #define SET_ORDER(opt, idx) { if (strcasecmp(token, opt) == 0) order[idx] = highest_order++; }
                         char *walk, *token;
-                        int c = 0;
                         walk = token = dest_value;
                         while (*walk != '\0') {
                                 while ((*walk != ',') && (*walk != '\0'))
@@ -139,7 +144,7 @@ int load_configuration(const char *configfile) {
         }
         fclose(handle);
 
-#ifndef DZEN
+#if !defined(DZEN) && !defined(XMOBAR)
         if (wmii_path == NULL)
                 exit(EXIT_FAILURE);
 #endif