From 4609477ac0522c053ec6ca55d78117746940136e Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 5 Dec 2022 12:45:19 -0500 Subject: [PATCH] LibCore: Support XDG_CONFIG_HOME when determing the user's config path And default to a path commonly used depending on the operating system. --- Userland/Libraries/LibCore/StandardPaths.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibCore/StandardPaths.cpp b/Userland/Libraries/LibCore/StandardPaths.cpp index f0d4fc7b2c6..49e20408c39 100644 --- a/Userland/Libraries/LibCore/StandardPaths.cpp +++ b/Userland/Libraries/LibCore/StandardPaths.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -51,9 +52,16 @@ DeprecatedString StandardPaths::downloads_directory() DeprecatedString StandardPaths::config_directory() { + if (auto* config_directory = getenv("XDG_CONFIG_HOME")) + return LexicalPath::canonicalized_path(config_directory); + StringBuilder builder; builder.append(home_directory()); +#if defined(AK_OS_MACOS) + builder.append("/Library/Preferences"sv); +#else builder.append("/.config"sv); +#endif return LexicalPath::canonicalized_path(builder.to_deprecated_string()); }