diff options
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index f13843a3..211b532e 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -17,6 +17,7 @@ #include "../config/ConfigValue.hpp" #include "../managers/CursorManager.hpp" +#include "../hyprerror/HyprError.hpp" static void trimTrailingComma(std::string& str) { if (!str.empty() && str.back() == ',') @@ -497,6 +498,29 @@ std::string layoutsRequest(eHyprCtlOutputFormat format, std::string request) { return result; } +std::string configErrorsRequest(eHyprCtlOutputFormat format, std::string request) { + std::string result = ""; + std::string currErrors = g_pConfigManager->getErrors(); + CVarList errLines(currErrors, 0, '\n'); + if (format == eHyprCtlOutputFormat::FORMAT_JSON) { + result += "["; + for (auto line : errLines) { + result += std::format( + R"#( + "{}",)#", + + escapeJSONStrings(line)); + } + trimTrailingComma(result); + result += "\n]\n"; + } else { + for (auto line : errLines) { + result += std::format("{}\n", line); + } + } + return result; +} + std::string devicesRequest(eHyprCtlOutputFormat format, std::string request) { std::string result = ""; @@ -1531,6 +1555,7 @@ CHyprCtl::CHyprCtl() { registerCommand(SHyprCtlCommand{"animations", true, animationsRequest}); registerCommand(SHyprCtlCommand{"rollinglog", true, rollinglogRequest}); registerCommand(SHyprCtlCommand{"layouts", true, layoutsRequest}); + registerCommand(SHyprCtlCommand{"configerrors", true, configErrorsRequest}); registerCommand(SHyprCtlCommand{"monitors", false, monitorsRequest}); registerCommand(SHyprCtlCommand{"reload", false, reloadRequest}); |
