summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-05 15:40:03 +0000
committerGitHub <noreply@github.com>2025-12-05 15:40:03 +0000
commit016eb7a23db54cb33ed722f682c7171027a91945 (patch)
tree47e9a200d1048a2a4d6b10fe7eae0bee4822c0a5 /src/config
parentec6756f961b5b6b12a53ec0387632e4495529f28 (diff)
start: init start-hyprland and safe mode (#12484)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigDescriptions.hpp6
-rw-r--r--src/config/ConfigManager.cpp39
-rw-r--r--src/config/ConfigManager.hpp2
3 files changed, 40 insertions, 7 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp
index a30b7b3d..85655dfd 100644
--- a/src/config/ConfigDescriptions.hpp
+++ b/src/config/ConfigDescriptions.hpp
@@ -1322,6 +1322,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.data = SConfigOptionDescription::SBoolData{false},
},
SConfigOptionDescription{
+ .value = "misc:disable_watchdog_warning",
+ .description = "whether to disable the warning about not using start-hyprland.",
+ .type = CONFIG_OPTION_BOOL,
+ .data = SConfigOptionDescription::SBoolData{false},
+ },
+ SConfigOptionDescription{
.value = "misc:lockdead_screen_delay",
.description = "the delay in ms after the lockdead screen appears if the lock screen did not appear after a lock event occurred.",
.type = CONFIG_OPTION_INT,
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() {
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index a13547b5..1055e5f2 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -317,7 +317,7 @@ class CConfigManager {
// internal methods
void setDefaultAnimationVars();
std::optional<std::string> resetHLConfig();
- std::optional<std::string> generateConfig(std::string configPath);
+ std::optional<std::string> generateConfig(std::string configPath, bool safeMode = false);
std::optional<std::string> verifyConfigExists();
void reloadRuleConfigs();