diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-04-30 09:56:13 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-05-04 16:50:35 +0200 |
commit | ac30733800b69dcb1589adcba6a42b20fa763e8f (patch) | |
tree | 53b0d07359563439e09eb3fa8ca81436e1bd73f8 /src | |
parent | a8225dc54c019788722bda3bda8d55151c1ccdef (diff) | |
download | biboumi-ac30733800b69dcb1589adcba6a42b20fa763e8f.tar.gz biboumi-ac30733800b69dcb1589adcba6a42b20fa763e8f.tar.bz2 biboumi-ac30733800b69dcb1589adcba6a42b20fa763e8f.tar.xz biboumi-ac30733800b69dcb1589adcba6a42b20fa763e8f.zip |
Search for the config file in $XDG_CONFIG_DIR/biboumi.
This environment variable points to the location the user expects to
find every program’s config file, or if it isn’t set, ~/.config/biboumi
(with a fallback to . if $HOME isn’t set).
fix #2553
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 15 |
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; |