diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-12-05 15:40:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-05 15:40:03 +0000 |
| commit | 016eb7a23db54cb33ed722f682c7171027a91945 (patch) | |
| tree | 47e9a200d1048a2a4d6b10fe7eae0bee4822c0a5 /src/config/ConfigManager.cpp | |
| parent | ec6756f961b5b6b12a53ec0387632e4495529f28 (diff) | |
start: init start-hyprland and safe mode (#12484)
Diffstat (limited to 'src/config/ConfigManager.cpp')
| -rw-r--r-- | src/config/ConfigManager.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d39a33ee..bde4ebc0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -498,6 +498,7 @@ CConfigManager::CConfigManager() { registerConfigVar("misc:render_unfocused_fps", Hyprlang::INT{15}); registerConfigVar("misc:disable_xdg_env_checks", Hyprlang::INT{0}); registerConfigVar("misc:disable_hyprland_guiutils_check", Hyprlang::INT{0}); + registerConfigVar("misc:disable_watchdog_warning", Hyprlang::INT{0}); registerConfigVar("misc:lockdead_screen_delay", Hyprlang::INT{1000}); registerConfigVar("misc:enable_anr_dialog", Hyprlang::INT{1}); registerConfigVar("misc:anr_missed_pings", Hyprlang::INT{5}); @@ -914,7 +915,7 @@ void CConfigManager::reloadRuleConfigs() { } } -std::optional<std::string> CConfigManager::generateConfig(std::string configPath) { +std::optional<std::string> CConfigManager::generateConfig(std::string configPath, bool safeMode) { std::string parentPath = std::filesystem::path(configPath).parent_path(); if (!parentPath.empty()) { @@ -931,7 +932,14 @@ std::optional<std::string> CConfigManager::generateConfig(std::string configPath Debug::log(WARN, "No config file found; attempting to generate."); std::ofstream ofs; ofs.open(configPath, std::ios::trunc); - ofs << AUTOGENERATED_PREFIX << EXAMPLE_CONFIG; + if (!safeMode) { + ofs << AUTOGENERATED_PREFIX; + ofs << EXAMPLE_CONFIG; + } else { + std::string n = std::string{EXAMPLE_CONFIG}; + replaceInString(n, "\n$menu = hyprlauncher\n", "\n$menu = hyprland-run\n"); + ofs << n; + } ofs.close(); if (ofs.fail()) @@ -941,7 +949,16 @@ std::optional<std::string> CConfigManager::generateConfig(std::string configPath } std::string CConfigManager::getMainConfigPath() { - static std::string CONFIG_PATH = [this]() -> std::string { + static bool lastSafeMode = g_pCompositor->m_safeMode; + static auto getCfgPath = [this]() -> std::string { + lastSafeMode = g_pCompositor->m_safeMode; + m_firstExecDispatched = false; + + if (g_pCompositor->m_safeMode) { + const auto CONFIGPATH = g_pCompositor->m_instancePath + "/recoverycfg.conf"; + return generateConfig(CONFIGPATH, false).value(); + } + if (!g_pCompositor->m_explicitConfigPath.empty()) return g_pCompositor->m_explicitConfigPath; @@ -956,7 +973,13 @@ std::string CConfigManager::getMainConfigPath() { return generateConfig(CONFIGPATH).value(); } else throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME are set in the environment. Could not find config in XDG_CONFIG_DIRS or /etc/xdg."); - }(); + }; + static std::string CONFIG_PATH = getCfgPath(); + + if (lastSafeMode != g_pCompositor->m_safeMode) { + CONFIG_PATH = getCfgPath(); + m_config->changeRootPath(CONFIG_PATH.c_str()); + } return CONFIG_PATH; } @@ -1415,7 +1438,6 @@ void CConfigManager::init() { reload(); }); - const std::string CONFIGPATH = getMainConfigPath(); reload(); m_isFirstLaunch = false; @@ -1637,7 +1659,12 @@ void CConfigManager::dispatchExecOnce() { g_pInputManager->setTabletConfigs(); // check for user's possible errors with their setup and notify them if needed - g_pCompositor->performUserChecks(); + // this is additionally guarded because exiting safe mode will re-run this. + static bool once = true; + if (once) { + g_pCompositor->performUserChecks(); + once = false; + } } void CConfigManager::dispatchExecShutdown() { |
