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
This commit is contained in:
committed by
Florent Le Coz
parent
a8225dc54c
commit
ac30733800
@@ -8,6 +8,7 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
@@ -67,8 +68,20 @@ int main(int ac, char** av)
|
||||
{
|
||||
if (ac > 1)
|
||||
Config::filename = av[1];
|
||||
else
|
||||
{
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user