summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-01-24 20:30:12 +0000
committerVaxry <vaxry@vaxry.net>2025-01-24 20:30:21 +0000
commitd8f79d7678f428738f3173020109bd7b7fbd0840 (patch)
tree8efc7a843e1f82cd7fcfb3c544124075a7d68782 /src/config
parent80b2fd135b45f2c2e41ceb312314908f6a3e7b30 (diff)
core: add --verify-config to verify the config with Hyprland
fixes #9135
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigManager.cpp30
-rw-r--r--src/config/ConfigManager.hpp8
2 files changed, 28 insertions, 10 deletions
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<int64_t* const*>(m_pConfig->getConfigValuePtr("debug:disable_logs")->getDataStaticPtr());
Debug::disableTime = reinterpret_cast<int64_t* const*>(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<std::string> 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");
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 31ad81cd..564c1ebf 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -144,6 +144,7 @@ class CConfigManager {
void init();
void reload();
+ std::string verify();
int getDeviceInt(const std::string&, const std::string&, const std::string& fallback = "");
float getDeviceFloat(const std::string&, const std::string&, const std::string& fallback = "");
@@ -257,9 +258,10 @@ class CConfigManager {
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollMouse; }},
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollTouchpad; }}};
- bool m_bWantsMonitorReload = false;
- bool m_bNoMonitorReload = false;
- bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
+ bool m_bWantsMonitorReload = false;
+ bool m_bNoMonitorReload = false;
+ bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
+ bool m_bLastConfigVerificationWasSuccessful = true;
private:
UP<Hyprlang::CConfig> m_pConfig;