aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-03-18 19:48:18 +0100
committerWolfgang Müller2021-04-27 12:28:35 +0200
commit8a67da3011d0efe1ded96f4ef66085fa90ccb4c6 (patch)
tree8a90b9081272e273dea4d39f0c0c70030bb28d1f /conf.c
parent03b67742f6e3939ceae5f9587c60391d35259f6d (diff)
downloadcwm-8a67da3011d0efe1ded96f4ef66085fa90ccb4c6.tar.gz
Migrate to an XDG-compliant config file location
Diffstat (limited to '')
-rw-r--r--conf.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/conf.c b/conf.c
index 0d0a852..9919597 100644
--- a/conf.c
+++ b/conf.c
@@ -271,6 +271,7 @@ void
conf_init(struct conf *c)
{
const char *home;
+ const char *xdg_config;
struct passwd *pw;
unsigned int i;
@@ -305,15 +306,20 @@ conf_init(struct conf *c)
c->font = xstrdup("sans-serif:pixelsize=14:bold");
c->wmname = xstrdup("CWM");
- home = getenv("HOME");
- if ((home == NULL) || (*home == '\0')) {
- pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_dir != NULL && *pw->pw_dir != '\0')
- home = pw->pw_dir;
- else
- home = "/";
+ xdg_config = getenv("XDG_CONFIG_HOME");
+ if ((xdg_config == NULL) || (*xdg_config == '\0')) {
+ home = getenv("HOME");
+ if ((home == NULL) || (*home == '\0')) {
+ pw = getpwuid(getuid());
+ if (pw != NULL && pw->pw_dir != NULL && *pw->pw_dir != '\0')
+ home = pw->pw_dir;
+ else
+ home = "/";
+ }
+ xasprintf(&c->conf_file, "%s/.config/cwm/cwmrc", home);
+ } else {
+ xasprintf(&c->conf_file, "%s/cwm/cwmrc", xdg_config);
}
- xasprintf(&c->conf_file, "%s/%s", home, ".cwmrc");
}
void