mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-15 20:13:49 -07:00
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
This commit is contained in:
@@ -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});
|
||||
|
Reference in New Issue
Block a user