Merge pull request #193 from Robinhuett/custom_alt

feat(custom): Add field for additional data to json
This commit is contained in:
Alex 2019-02-26 12:18:47 +01:00 committed by GitHub
commit 470f539346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -22,6 +22,7 @@ class Custom : public ALabel {
const std::string name_; const std::string name_;
std::string text_; std::string text_;
std::string alt_;
std::string tooltip_; std::string tooltip_;
std::string class_; std::string class_;
std::string prevclass_; std::string prevclass_;

View File

@ -91,6 +91,7 @@ auto waybar::modules::Custom::update() -> void
} }
auto str = fmt::format(format_, text_, auto str = fmt::format(format_, text_,
fmt::arg("alt", alt_),
fmt::arg("icon", getIcon(percentage_)), fmt::arg("icon", getIcon(percentage_)),
fmt::arg("percentage", percentage_)); fmt::arg("percentage", percentage_));
label_.set_markup(str); label_.set_markup(str);
@ -144,6 +145,7 @@ void waybar::modules::Custom::parseOutputJson()
while (getline(output, line)) { while (getline(output, line)) {
auto parsed = parser_.parse(line); auto parsed = parser_.parse(line);
text_ = Glib::Markup::escape_text(parsed["text"].asString()); text_ = Glib::Markup::escape_text(parsed["text"].asString());
alt_ = Glib::Markup::escape_text(parsed["alt"].asString());
tooltip_ = parsed["tooltip"].asString(); tooltip_ = parsed["tooltip"].asString();
class_ = parsed["class"].asString(); class_ = parsed["class"].asString();
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) { if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) {