From ae62725ab027691e97eadf429a5fb2586fb99a32 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 7 May 2021 21:39:14 +0200 Subject: [PATCH] XDG compliance --- sources/plugin/Config.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sources/plugin/Config.cpp b/sources/plugin/Config.cpp index 554e6af..9feb9dc 100644 --- a/sources/plugin/Config.cpp +++ b/sources/plugin/Config.cpp @@ -46,10 +46,19 @@ const std::string &get_configuration_dir() path.append(DISTRHO_PLUGIN_NAME "/"); mkdir(path.c_str(), 0755); #else - path = get_home_directory(); - if (path.empty()) - return std::string(); - path.append(".config/"); + if (const char *env = std::getenv("XDG_CONFIG_HOME")) { + if (env[0] == '/') { + path = env; + if (path.back() != '/') + path.push_back('/'); + } + } + if (path.empty()) { + path = get_home_directory(); + if (path.empty()) + return std::string(); + path.append(".config/"); + } mkdir(path.c_str(), 0755); path.append(DISTRHO_PLUGIN_NAME "/"); mkdir(path.c_str(), 0755);