diff options
| author | zakk4223 <zakk@rsdio.com> | 2024-03-20 21:55:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 01:55:13 +0000 |
| commit | 4c796683c05a0eaccc14aae8875f06972f9f3c5e (patch) | |
| tree | a2605abdd24aa8a1c444adceee70cbdb450d296b /src/debug/HyprCtl.cpp | |
| parent | 214ec82ba7dcbb33b45963d13b84f9bd6c913614 (diff) | |
config: Config error limit/hyprctl (#5165)
* Add error_limit to limit the number of config error messages shown in notification
* Add configerrors hyprctl command
* Formatting
* Formatting for not my code
* Use CVarList, add escapeJSONStrings
* Add indication there are more undisplayed errors
* Restore suppress_errors; move getErrors() to ConfigManager
* Formatting, wtf
* Format
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}); |
