From ce66af2aefba9e0877e4c5391021461895be11bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Tue, 15 Sep 2020 01:50:54 +0200 Subject: [PATCH] support xdg directory specification --- src/config.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/config.cpp b/src/config.cpp index 0ed706a..a8c7ddc 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -8,6 +8,18 @@ Config::Config() { const auto home_path = filesystem::get_home_path(); + if(std::getenv("XDG_RUNTIME_DIR") != nullptr) { + if(auto ptr = std::getenv("XDG_CONFIG_HOME")) { + boost::filesystem::path config_dir(ptr); + home_juci_path = config_dir / "juci"; + return; + } + else { + boost::filesystem::path config_dir(home_path / "config"); + home_juci_path = config_dir / "juci"; + return; + } + } if(home_path.empty()) throw std::runtime_error("Could not find home path"); home_juci_path = home_path / ".juci";