From d8f79d7678f428738f3173020109bd7b7fbd0840 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 24 Jan 2025 20:30:12 +0000 Subject: core: add --verify-config to verify the config with Hyprland fixes #9135 --- src/config/ConfigManager.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index f5c9b3ee..c5d70329 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -19,6 +19,7 @@ #include "../render/Renderer.hpp" #include "../hyprerror/HyprError.hpp" #include "../managers/input/InputManager.hpp" +#include "../managers/eventLoop/EventLoopManager.hpp" #include "../managers/LayoutManager.hpp" #include "../managers/EventManager.hpp" #include "../debug/HyprNotificationOverlay.hpp" @@ -730,15 +731,18 @@ CConfigManager::CConfigManager() { resetHLConfig(); - Debug::log(INFO, - "!!!!HEY YOU, YES YOU!!!!: further logs to stdout / logfile are disabled by default. BEFORE SENDING THIS LOG, ENABLE THEM. Use debug:disable_logs = false to do so: " - "https://wiki.hyprland.org/Configuring/Variables/#debug"); + if (!g_pCompositor->m_bOnlyConfigVerification) { + Debug::log( + INFO, + "!!!!HEY YOU, YES YOU!!!!: further logs to stdout / logfile are disabled by default. BEFORE SENDING THIS LOG, ENABLE THEM. Use debug:disable_logs = false to do so: " + "https://wiki.hyprland.org/Configuring/Variables/#debug"); + } Debug::disableLogs = reinterpret_cast(m_pConfig->getConfigValuePtr("debug:disable_logs")->getDataStaticPtr()); Debug::disableTime = reinterpret_cast(m_pConfig->getConfigValuePtr("debug:disable_time")->getDataStaticPtr()); - if (ERR.has_value()) - g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0}); + if (g_pEventLoopManager && ERR.has_value()) + g_pEventLoopManager->doLater([ERR] { g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0}); }); } std::optional CConfigManager::generateConfig(std::string configPath) { @@ -820,11 +824,23 @@ void CConfigManager::reload() { EMIT_HOOK_EVENT("preConfigReload", nullptr); setDefaultAnimationVars(); resetHLConfig(); - configCurrentPath = getMainConfigPath(); - const auto ERR = m_pConfig->parse(); + configCurrentPath = getMainConfigPath(); + const auto ERR = m_pConfig->parse(); + m_bLastConfigVerificationWasSuccessful = !ERR.error; postConfigReload(ERR); } +std::string CConfigManager::verify() { + setDefaultAnimationVars(); + resetHLConfig(); + configCurrentPath = getMainConfigPath(); + const auto ERR = m_pConfig->parse(); + m_bLastConfigVerificationWasSuccessful = !ERR.error; + if (ERR.error) + return ERR.getError(); + return "config ok"; +} + void CConfigManager::setDefaultAnimationVars() { m_AnimationTree.createNode("__internal_fadeCTM"); m_AnimationTree.createNode("global"); -- cgit v1.2.3