summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 62a28a5..80462cb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,6 +8,7 @@
#include <iostream>
#include <memory>
#include <atomic>
+#include <cstdlib>
#include <signal.h>
@@ -68,7 +69,19 @@ int main(int ac, char** av)
if (ac > 1)
Config::filename = av[1];
else
- Config::filename = "biboumi.cfg";
+ {
+ const char* xdg_config_home = getenv("XDG_CONFIG_HOME");
+ if (xdg_config_home)
+ Config::filename = std::string{xdg_config_home} + "/" "biboumi" "/" "biboumi.cfg";
+ else
+ {
+ const char* home = getenv("HOME");
+ if (home)
+ Config::filename = std::string{home} + "/" ".config" "/" "biboumi" "/" "biboumi.cfg";
+ else
+ Config::filename = "biboumi.cfg";
+ }
+ }
Config::file_must_exist = true;
std::cerr << "Using configuration file: " << Config::filename << std::endl;