fix: allow custom format
This commit is contained in:
@ -45,18 +45,21 @@ WindowCount::~WindowCount() {
|
|||||||
auto WindowCount::update() -> void {
|
auto WindowCount::update() -> void {
|
||||||
std::lock_guard<std::mutex> lg(mutex_);
|
std::lock_guard<std::mutex> lg(mutex_);
|
||||||
|
|
||||||
if (!format_.empty()) {
|
std::string format = config_["format"].asString();
|
||||||
label_.show();
|
std::string formattedText;
|
||||||
|
|
||||||
|
if (!format.empty()) {
|
||||||
|
formattedText = fmt::format(fmt::runtime(format), workspace_.windows);
|
||||||
label_.set_markup(waybar::util::rewriteString(
|
label_.set_markup(waybar::util::rewriteString(
|
||||||
fmt::format(fmt::runtime(format_), fmt::arg("count", workspace_.windows)),
|
formattedText,
|
||||||
config_["rewrite"]));
|
config_["rewrite"]));
|
||||||
|
label_.show();
|
||||||
} else {
|
} else {
|
||||||
|
// Default display
|
||||||
|
label_.set_text(fmt::format("{}", workspace_.windows));
|
||||||
label_.hide();
|
label_.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the count as the label text
|
|
||||||
label_.set_text(fmt::format("{}", workspace_.windows));
|
|
||||||
|
|
||||||
AAppIconLabel::update();
|
AAppIconLabel::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +128,6 @@ void WindowCount::queryActiveWorkspace() {
|
|||||||
|
|
||||||
void WindowCount::onEvent(const std::string& ev) {
|
void WindowCount::onEvent(const std::string& ev) {
|
||||||
queryActiveWorkspace();
|
queryActiveWorkspace();
|
||||||
update();
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user