fix(linux)!: use XDG spec for fetching Linux configuration directory (#2034)
This commit is contained in:
@@ -99,12 +99,22 @@ namespace platf {
|
|||||||
|
|
||||||
fs::path
|
fs::path
|
||||||
appdata() {
|
appdata() {
|
||||||
const char *homedir;
|
const char *dir;
|
||||||
if ((homedir = getenv("HOME")) == nullptr) {
|
|
||||||
homedir = getpwuid(geteuid())->pw_dir;
|
// May be set if running under a systemd service with the ConfigurationDirectory= option set.
|
||||||
|
if ((dir = getenv("CONFIGURATION_DIRECTORY")) != nullptr) {
|
||||||
|
return fs::path { dir } / "sunshine"sv;
|
||||||
|
}
|
||||||
|
// Otherwise, follow the XDG base directory specification:
|
||||||
|
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
|
if ((dir = getenv("XDG_CONFIG_HOME")) != nullptr) {
|
||||||
|
return fs::path { dir } / "sunshine"sv;
|
||||||
|
}
|
||||||
|
if ((dir = getenv("HOME")) == nullptr) {
|
||||||
|
dir = getpwuid(geteuid())->pw_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs::path { homedir } / ".config/sunshine"sv;
|
return fs::path { dir } / ".config/sunshine"sv;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
|||||||
Reference in New Issue
Block a user