From 136802519370e8ae90449bfb4f04a67ad207b469 Mon Sep 17 00:00:00 2001 From: viri Date: Fri, 29 Jul 2022 02:09:39 -0600 Subject: [PATCH] Implement $XDG_CONFIG_HOME on Unix systems --- src/spek-platform.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/spek-platform.cc b/src/spek-platform.cc index 2800f15..20ba37f 100644 --- a/src/spek-platform.cc +++ b/src/spek-platform.cc @@ -24,8 +24,14 @@ wxString spek_platform_config_path(const wxString& app_name) #ifdef OS_WIN wxFileName file_name(wxStandardPaths::Get().GetUserConfigDir(), wxEmptyString); #else - wxFileName file_name(wxGetHomeDir(), wxEmptyString); - file_name.AppendDir(".config"); + wxFileName file_name; + wxString xdg_config_home; + if (wxGetEnv("XDG_CONFIG_HOME", &xdg_config_home) && !xdg_config_home.IsEmpty()) { + file_name = wxFileName(xdg_config_home, wxEmptyString); + } else { + file_name = wxFileName(wxGetHomeDir(), wxEmptyString); + file_name.AppendDir(".config"); + } #endif file_name.AppendDir(app_name); file_name.Mkdir(0755, wxPATH_MKDIR_FULL);