From 899a70e75967c41fc6241790dbdd96e492bb9ef4 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sun, 7 Jan 2024 19:13:59 +0100 Subject: [PATCH] core: don't critically exit if env doesnt have home fixes #163 --- src/core/PortalManager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/PortalManager.cpp b/src/core/PortalManager.cpp index 40d4a14..98fb2df 100644 --- a/src/core/PortalManager.cpp +++ b/src/core/PortalManager.cpp @@ -202,12 +202,11 @@ CPortalManager::CPortalManager() { const auto XDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME"); const auto HOME = getenv("HOME"); - if (!HOME && !XDG_CONFIG_HOME) { - Debug::log(CRIT, "Cannot proceed: neither $HOME nor $XDG_CONFIG_HOME is present in env"); - throw "$HOME and $XDG_CONFIG_HOME both missing from env"; - } + if (!HOME && !XDG_CONFIG_HOME) + Debug::log(WARN, "neither $HOME nor $XDG_CONFIG_HOME is present in env"); - std::string path = XDG_CONFIG_HOME ? std::string{XDG_CONFIG_HOME} + "/hypr/xdph.conf" : std::string{HOME} + "/.config/hypr/xdph.conf"; + std::string path = + (!XDG_CONFIG_HOME && !HOME) ? "/tmp/xdph.conf" : (XDG_CONFIG_HOME ? std::string{XDG_CONFIG_HOME} + "/hypr/xdph.conf" : std::string{HOME} + "/.config/hypr/xdph.conf"); m_sConfig.config = std::make_unique(path.c_str(), Hyprlang::SConfigOptions{.allowMissingConfig = true});