mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #129 from Robinhuett/custom-module-icon
Add format-icons to custom module
This commit is contained in:
commit
513278597a
@ -25,6 +25,7 @@ class Custom : public ALabel {
|
||||
std::string tooltip_;
|
||||
std::string class_;
|
||||
std::string prevclass_;
|
||||
int percentage_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
waybar::util::command::res output_;
|
||||
waybar::util::JsonParser parser_;
|
||||
|
@ -87,7 +87,9 @@ auto waybar::modules::Custom::update() -> void
|
||||
parseOutputRaw();
|
||||
}
|
||||
|
||||
auto str = fmt::format(format_, text_);
|
||||
auto str = fmt::format(format_, text_,
|
||||
fmt::arg("icon", getIcon(percentage_)),
|
||||
fmt::arg("percentage", percentage_));
|
||||
label_.set_markup(str);
|
||||
if (text_ == tooltip_) {
|
||||
label_.set_tooltip_text(str);
|
||||
@ -139,6 +141,11 @@ void waybar::modules::Custom::parseOutputJson()
|
||||
text_ = parsed["text"].asString();
|
||||
tooltip_ = parsed["tooltip"].asString();
|
||||
class_ = parsed["class"].asString();
|
||||
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isUInt()) {
|
||||
percentage_ = parsed["percentage"].asUInt();
|
||||
} else {
|
||||
percentage_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user