feat: Respect XDG_CONFIG_HOME in server/client

This commit is contained in:
Nick Bolton 2024-10-14 16:36:02 +01:00
parent 9c4f6e6d0b
commit 636e3eab96

View file

@ -19,6 +19,7 @@
#include "arch/unix/ArchFileUnix.h"
#include <cstring>
#include <filesystem>
#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
@ -100,17 +101,21 @@ std::string ArchFileUnix::getPluginDirectory() {
}
std::string ArchFileUnix::getProfileDirectory() {
String dir;
if (!m_profileDirectory.empty()) {
dir = m_profileDirectory;
return m_profileDirectory;
} else {
const std::filesystem::path homeDir = getUserDirectory();
#if WINAPI_XWINDOWS
dir = getUserDirectory().append("/.config/" DESKFLOW_APP_NAME);
const auto xdgDir = std::getenv("XDG_CONFIG_HOME");
if (xdgDir != nullptr) {
return std::filesystem::path(xdgDir) / DESKFLOW_APP_NAME;
} else {
return homeDir / ".config" / DESKFLOW_APP_NAME;
}
#else
dir = getUserDirectory().append("/Library/" DESKFLOW_APP_NAME);
return homeDir / "Library" / DESKFLOW_APP_NAME;
#endif
}
return dir;
}
std::string