mirror of https://github.com/polybar/polybar.git
parent
57e8914fa6
commit
2fea813c3d
|
@ -60,6 +60,7 @@ namespace drawtypes {
|
|||
string get() const;
|
||||
operator bool();
|
||||
label_t clone();
|
||||
void clear();
|
||||
void reset_tokens();
|
||||
bool has_token(const string& token);
|
||||
void replace_token(const string& token, string replacement);
|
||||
|
|
|
@ -24,6 +24,10 @@ namespace drawtypes {
|
|||
m_margin, m_maxlen, m_ellipsis, move(tokens));
|
||||
}
|
||||
|
||||
void label::clear() {
|
||||
m_tokenized.clear();
|
||||
}
|
||||
|
||||
void label::reset_tokens() {
|
||||
m_tokenized = m_text;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "modules/github.hpp"
|
||||
#include <cassert>
|
||||
|
||||
#include "drawtypes/label.hpp"
|
||||
#include "modules/github.hpp"
|
||||
|
||||
#include "modules/meta/base.inl"
|
||||
|
||||
|
@ -23,6 +25,8 @@ namespace modules {
|
|||
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "Notifications: %notifications%");
|
||||
m_label->replace_token("%notifications%", m_empty_notifications ? "0" : "");
|
||||
}
|
||||
|
||||
assert(static_cast<bool>(m_label));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,9 +54,11 @@ namespace modules {
|
|||
notifications++;
|
||||
}
|
||||
|
||||
if (m_label) {
|
||||
if (notifications || m_empty_notifications) {
|
||||
m_label->reset_tokens();
|
||||
m_label->replace_token("%notifications%", notifications || m_empty_notifications ? to_string(notifications) : "");
|
||||
m_label->replace_token("%notifications%", to_string(notifications));
|
||||
} else {
|
||||
m_label->clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue