aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--conf.c22
-rw-r--r--cwm.19
-rw-r--r--cwmrc.57
3 files changed, 25 insertions, 13 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
diff --git a/cwm.1 b/cwm.1
index 74dbd36..49c90a3 100644
--- a/cwm.1
+++ b/cwm.1
@@ -39,7 +39,7 @@ Specify an alternative configuration file.
By default,
.Nm
loads
-.Pa ~/.cwmrc ,
+.Pa $XDG_CONFIG_HOME/cwm/cwmrc ,
if present.
Any error messages from lines in the configuration file will be sent to
.Em stderr ;
@@ -244,12 +244,15 @@ starts on this display unless the
option is given.
.El
.Sh FILES
-.Bl -tag -width "~/.cwmrcXX" -compact
-.It Pa ~/.cwmrc
+.Bl -tag -width "$XDG_CONFIG_HOME/cwm/cwmrcXXX" -compact
+.It Pa $XDG_CONFIG_HOME/cwm/cwmrc
Default
.Nm
configuration file.
.El
+.Pp
+If $XDG_CONFIG_HOME is unset or empty, it will default to
+.Em ~/.config
.Sh SEE ALSO
.Xr cwmrc 5
.Sh HISTORY
diff --git a/cwmrc.5 b/cwmrc.5
index 10ae69f..9d79905 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -431,12 +431,15 @@ Move pointer 10 times
pixels left.
.El
.Sh FILES
-.Bl -tag -width "~/.cwmrcXXX" -compact
-.It Pa ~/.cwmrc
+.Bl -tag -width "$XDG_CONFIG_HOME/cwm/cwmrcXXX" -compact
+.It Pa $XDG_CONFIG_HOME/cwm/cwmrc
Default
.Xr cwm 1
configuration file.
.El
+.Pp
+If $XDG_CONFIG_HOME is unset or empty, it will default to
+.Em ~/.config
.Sh EXAMPLES
.Bd -literal
# Set default Xft(3) font