summaryrefslogtreecommitdiff
path: root/src/main.cpp
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/main.cpp
parent80b2fd135b45f2c2e41ceb312314908f6a3e7b30 (diff)
core: add --verify-config to verify the config with Hyprland
fixes #9135
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index bb5e5622..d244f10f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,6 +27,7 @@ static void help() {
--wayland-fd FD - Sets the Wayland socket fd (for Wayland socket handover)
--systeminfo - Prints system infos
--i-am-really-stupid - Omits root user privileges check (why would you do that?)
+ --verify-config - Do not run Hyprland, only print if the config has any errors
--version -v - Print this binary's version)");
}
@@ -49,7 +50,7 @@ int main(int argc, char** argv) {
std::string configPath;
std::string socketName;
int socketFd = -1;
- bool ignoreSudo = false;
+ bool ignoreSudo = false, verifyConfig = false;
std::vector<std::string> args{argv + 1, argv + argc};
@@ -124,6 +125,9 @@ int main(int argc, char** argv) {
} else if (*it == "--systeminfo") {
std::println("{}", systemInfoRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, ""));
return 0;
+ } else if (*it == "--verify-config") {
+ verifyConfig = true;
+ continue;
} else {
std::println(stderr, "[ ERROR ] Unknown option '{}' !", *it);
help();
@@ -138,9 +142,8 @@ int main(int argc, char** argv) {
" Hint: Use the --i-am-really-stupid flag to omit that check.");
return 1;
- } else if (ignoreSudo && NInit::isSudo()) {
+ } else if (ignoreSudo && NInit::isSudo())
std::println("Superuser privileges check is omitted. I hope you know what you're doing.");
- }
if (socketName.empty() ^ (socketFd == -1)) {
std::println(stderr,
@@ -150,12 +153,13 @@ int main(int argc, char** argv) {
return 1;
}
- std::println("Welcome to Hyprland!");
+ if (!verifyConfig)
+ std::println("Welcome to Hyprland!");
// let's init the compositor.
// it initializes basic Wayland stuff in the constructor.
try {
- g_pCompositor = makeUnique<CCompositor>();
+ g_pCompositor = makeUnique<CCompositor>(verifyConfig);
g_pCompositor->explicitConfigPath = configPath;
} catch (const std::exception& e) {
std::println(stderr, "Hyprland threw in ctor: {}\nCannot continue.", e.what());
@@ -164,6 +168,9 @@ int main(int argc, char** argv) {
g_pCompositor->initServer(socketName, socketFd);
+ if (verifyConfig)
+ return !g_pConfigManager->m_bLastConfigVerificationWasSuccessful;
+
if (!envEnabled("HYPRLAND_NO_RT"))
NInit::gainRealTime();