fix: try $XDG_CONFIG_HOME first

This commit is contained in:
2026-02-27 16:10:13 +03:00
parent 25fbc7852d
commit 7638284616
2 changed files with 5 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
namespace clrsync::core namespace clrsync::core
{ {
const std::string GIT_SEMVER = "1.1.1+git.gf3e842d"; const std::string GIT_SEMVER = "1.1.2+git.g25fbc78";
const std::string version_string(); const std::string version_string();
} // namespace clrsync::core } // namespace clrsync::core

View File

@@ -4,6 +4,7 @@
#include "core/io/toml_file.hpp" #include "core/io/toml_file.hpp"
#include "core/palette/color.hpp" #include "core/palette/color.hpp"
#include <cstdlib>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@@ -68,6 +69,9 @@ Result<void> config::initialize(std::unique_ptr<clrsync::core::io::file> file)
std::filesystem::path config::get_user_config_dir() std::filesystem::path config::get_user_config_dir()
{ {
const char *xdg_config_home = std::getenv("XDG_CONFIG_HOME");
if (xdg_config_home && xdg_config_home[0] != '\0')
return normalize_path(xdg_config_home) / "clrsync";
std::filesystem::path home = normalize_path("~"); std::filesystem::path home = normalize_path("~");
return home / ".config" / "clrsync"; return home / ".config" / "clrsync";
} }