]> git.sur5r.net Git - i3/i3status/commitdiff
More sensible lookup order loading the config.
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sat, 23 Oct 2010 19:43:32 +0000 (17:43 -0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 23 Oct 2010 22:34:53 +0000 (00:34 +0200)
i3status.c
man/i3status.man

index 6d6fbc7f1f2e9064d87dde790a9bcbab16ed2ab6..eff6da411c0e92150e06f73e21876bfbcef8713f 100644 (file)
@@ -117,9 +117,14 @@ static char *resolve_tilde(const char *path) {
 }
 
 static char *get_config_path() {
 }
 
 static char *get_config_path() {
-        /* 1: check for $XDG_CONFIG_HOME/i3/config */
         char *xdg_config_home, *xdg_config_dirs, *config_path;
 
         char *xdg_config_home, *xdg_config_dirs, *config_path;
 
+        /* 1: check the traditional path under the home directory */
+        config_path = resolve_tilde("~/.i3status.conf");
+        if (path_exists(config_path))
+                return config_path;
+
+        /* 2: check for $XDG_CONFIG_HOME/i3status/config */
         if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)
                 xdg_config_home = "~/.config";
 
         if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)
                 xdg_config_home = "~/.config";
 
@@ -132,7 +137,12 @@ static char *get_config_path() {
                 return config_path;
         free(config_path);
 
                 return config_path;
         free(config_path);
 
-        /* 2: check for $XDG_CONFIG_DIRS/i3/config */
+        /* 3: check the traditional path under /etc */
+        config_path = SYSCONFDIR "/i3status.conf";
+        if (path_exists(config_path))
+            return sstrdup(config_path);
+
+        /* 4: check for $XDG_CONFIG_DIRS/i3status/config */
         if ((xdg_config_dirs = getenv("XDG_CONFIG_DIRS")) == NULL)
                 xdg_config_dirs = "/etc/xdg";
 
         if ((xdg_config_dirs = getenv("XDG_CONFIG_DIRS")) == NULL)
                 xdg_config_dirs = "/etc/xdg";
 
@@ -152,18 +162,10 @@ static char *get_config_path() {
         }
         free(buf);
 
         }
         free(buf);
 
-        /* 3: check traditional paths */
-        config_path = resolve_tilde("~/.i3status.conf");
-        if (path_exists(config_path))
-                return config_path;
-
-        config_path = strdup(SYSCONFDIR "/i3status.conf");
-        if (!path_exists(config_path))
-                die("Neither $XDG_CONFIG_HOME/i3status/config, nor "
-                    "$XDG_CONFIG_DIRS/i3status/config, nor ~/.i3status.conf nor "
-                    SYSCONFDIR "/i3status.conf exist.");
-
-        return config_path;
+        die("Unable to find the configuration file (looked at "
+                "~/.i3status/config, $XDG_CONFIG_HOME/i3status/config, "
+                "/etc/i3status/config and $XDG_CONFIG_DIRS/i3status/config)");
+        return NULL;
 }
 
 int main(int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
index a8f461f44050eb9fce278d6849ec45910ad60d96..57a991c85483c43ba875244744637f1635807937 100644 (file)
@@ -17,10 +17,10 @@ i3status [-c configfile] [-h] [-v]
 Specifies an alternate configuration file path. By default, i3status looks for
 configuration files in the following order:
 
 Specifies an alternate configuration file path. By default, i3status looks for
 configuration files in the following order:
 
-1. ~/.config/i3status/config (or $XDG_CONFIG_HOME/i3status/config if set)
-2. /etc/xdg/i3status/config (or $XDG_CONFIG_DIRS/i3status/config if set)
-3. ~/.i3status.conf
-4. /etc/i3status.conf (or SYSCONFDIR/i3status.conf if set at compile-time)
+1. ~/.i3status/config
+2. ~/.config/i3status/config (or $XDG_CONFIG_HOME/i3status/config if set)
+3. /etc/i3status/config
+4. /etc/xdg/i3status/config (or $XDG_CONFIG_DIRS/i3status/config if set)
 
 == DESCRIPTION
 
 
 == DESCRIPTION