config: Use XDG_CONFIG_HOME

This commit is contained in:
Colin Kinloch 2023-09-11 23:37:36 +01:00
parent e9bcb67930
commit 33a9def787

View file

@ -61,9 +61,11 @@ void DivEngine::initConfDir() {
return; return;
} }
#else #else
// TODO this should check XDG_CONFIG_HOME first char* xdgConfigHome=getenv("XDG_CONFIG_HOME");
char* home=getenv("HOME"); char* home=getenv("HOME");
if (home==NULL) { if (xdgConfigHome) {
configPath=xdgConfigHome;
} else if (home==NULL) {
int uid=getuid(); int uid=getuid();
struct passwd* entry=getpwuid(uid); struct passwd* entry=getpwuid(uid);
if (entry==NULL) { if (entry==NULL) {
@ -79,8 +81,9 @@ void DivEngine::initConfDir() {
#ifdef __APPLE__ #ifdef __APPLE__
configPath+="/Library/Application Support"; configPath+="/Library/Application Support";
#else #else
// FIXME this doesn't honour XDG_CONFIG_HOME *at all* if (xdgConfigHome==NULL) {
configPath+="/.config"; configPath+="/.config";
}
#endif // __APPLE__ #endif // __APPLE__
#endif // __HAIKU__ #endif // __HAIKU__
#ifdef __APPLE__ #ifdef __APPLE__