mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 05:19:48 +01:00
config: don't crash when getenv HOME returns null (#398)
This commit is contained in:
parent
9737bf6484
commit
01bf48ed96
1 changed files with 6 additions and 1 deletions
|
@ -23,7 +23,12 @@ static std::string getConfigDir() {
|
|||
if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute())
|
||||
return xdgConfigHome;
|
||||
|
||||
return getenv("HOME") + std::string("/.config");
|
||||
static const char* home = getenv("HOME");
|
||||
|
||||
if (!home)
|
||||
throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME is set in the environment. Cannot determine config directory.");
|
||||
|
||||
return home + std::string("/.config");
|
||||
}
|
||||
|
||||
static std::string getMainConfigPath() {
|
||||
|
|
Loading…
Reference in a new issue