X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fconfig.c;h=e39c19b66d3c5bfca96e7b71eb273a03e2133737;hb=1d122f32e6d2b0ae1f964dd755d769885c7bf1c2;hp=da1e5d198538aea34ff3da8ba35c7717ceec3b5d;hpb=34ba9fa9083c655e5ba06cecd46da157eb07d980;p=i3%2Fi3status diff --git a/src/config.c b/src/config.c index da1e5d1..e39c19b 100644 --- a/src/config.c +++ b/src/config.c @@ -1,11 +1,15 @@ +// vim:ts=8:expandtab #include #include #include #include #include +#include #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