From 88fc68aaf79ad817b13a5a9a81c68691219aa82d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 7 Aug 2016 00:05:06 +0100 Subject: [PATCH] Core: Obey the XDG basedir specification for environment variables --- src/core/config.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/config.c b/src/core/config.c index 6dfb6ea8c..d66baddb3 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -227,6 +227,12 @@ void mCoreConfigDirectory(char* out, size_t outLength) { return; } + char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); + if (xdgConfigHome && xdgConfigHome[0] == '/') { + snprintf(out, outLength, "%s/%s", xdgConfigHome, binaryName); + mkdir(out, 0755); + return; + } char* home = getenv("HOME"); snprintf(out, outLength, "%s/.config", home); mkdir(out, 0755);