From 79b0367e6c61063d2a6107afa2c5e53f90a575fb Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 1 Mar 2019 17:02:50 +0100 Subject: [PATCH] feat(custom): escape option --- src/modules/custom.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index b1f03e1a..a8cdeddd 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -124,7 +124,11 @@ void waybar::modules::Custom::parseOutputRaw() int i = 0; while (getline(output, line)) { if (i == 0) { - text_ = line; + if (config_["escape"].isBool() && config_["escape"].asBool()) { + text_ = Glib::Markup::escape_text(line); + } else { + text_ = line; + } tooltip_ = line; class_ = ""; } else if (i == 1) { @@ -144,8 +148,16 @@ void waybar::modules::Custom::parseOutputJson() std::string line; while (getline(output, line)) { auto parsed = parser_.parse(line); - text_ = parsed["text"].asString(); - alt_ = parsed["alt"].asString(); + if (config_["escape"].isBool() && config_["escape"].asBool()) { + text_ = Glib::Markup::escape_text(parsed["text"].asString()); + } else { + text_ = parsed["text"].asString(); + } + if (config_["escape"].isBool() && config_["escape"].asBool()) { + alt_ = Glib::Markup::escape_text(parsed["alt"].asString()); + } else { + alt_ = parsed["alt"].asString(); + } tooltip_ = parsed["tooltip"].asString(); class_ = parsed["class"].asString(); if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) {