summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreplanet <emeric.planet@gmail.com>2016-06-15 23:13:40 +0200
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2016-06-15 23:13:40 +0200
commit3a807af8555c5b056e384b40910071d22dca7706 (patch)
treea35d1a3aaec62a2ad313f14de03be689dcb8a250
parent7c0c82313ed072f99cbe3d8a56c2a62631e7ec89 (diff)
Default configuration paths ordered the same way as i3. Fixes #129 (#130)
-rw-r--r--i3status.c23
-rw-r--r--man/i3status.man8
2 files changed, 15 insertions, 16 deletions
diff --git a/i3status.c b/i3status.c
index 19ad5a3..e5e85bf 100644
--- a/i3status.c
+++ b/i3status.c
@@ -229,12 +229,7 @@ static char *resolve_tilde(const char *path) {
static char *get_config_path(void) {
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 */
+ /* 1: check for $XDG_CONFIG_HOME/i3status/config */
if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)
xdg_config_home = "~/.config";
@@ -247,15 +242,14 @@ static char *get_config_path(void) {
return config_path;
free(config_path);
- /* 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 */
+ /* 2: check for $XDG_CONFIG_DIRS/i3status/config */
if ((xdg_config_dirs = getenv("XDG_CONFIG_DIRS")) == NULL)
xdg_config_dirs = "/etc/xdg";
+ /* 3: check the traditional path under the home directory */
+ config_path = resolve_tilde("~/.i3status.conf");
+ if (path_exists(config_path))
+ return config_path;
char *buf = strdup(xdg_config_dirs);
char *tok = strtok(buf, ":");
while (tok != NULL) {
@@ -272,6 +266,11 @@ static char *get_config_path(void) {
}
free(buf);
+ /* 4: check the traditional path under /etc */
+ config_path = SYSCONFDIR "/i3status.conf";
+ if (path_exists(config_path))
+ return sstrdup(config_path);
+
die("Unable to find the configuration file (looked at "
"~/.i3status.conf, $XDG_CONFIG_HOME/i3status/config, "
"/etc/i3status.conf and $XDG_CONFIG_DIRS/i3status/config)");
diff --git a/man/i3status.man b/man/i3status.man
index 8508488..c43e4d3 100644
--- a/man/i3status.man
+++ b/man/i3status.man
@@ -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:
-1. ~/.i3status.conf
-2. ~/.config/i3status/config (or $XDG_CONFIG_HOME/i3status/config if set)
-3. /etc/i3status.conf
-4. /etc/xdg/i3status/config (or $XDG_CONFIG_DIRS/i3status/config if set)
+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
== DESCRIPTION