polybar/src/modules/counter.cpp

31 lines
686 B
C++
Raw Normal View History

2016-11-02 19:22:45 +00:00
#include "modules/counter.hpp"
2016-11-20 22:04:31 +00:00
#include "modules/meta/base.inl"
2016-11-19 05:22:44 +00:00
POLYBAR_NS
2016-11-02 19:22:45 +00:00
namespace modules {
2016-11-20 22:04:31 +00:00
template class module<counter_module>;
counter_module::counter_module(const bar_settings& bar, string name_)
: timer_module<counter_module>(bar, move(name_)) {
m_interval = m_conf.get(name(), "interval", m_interval);
2016-11-02 19:22:45 +00:00
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
}
bool counter_module::update() {
m_counter++;
return true;
}
2016-11-25 12:55:15 +00:00
bool counter_module::build(builder* builder, const string& tag) const {
2016-11-02 19:22:45 +00:00
if (tag == TAG_COUNTER) {
builder->node(to_string(m_counter));
return true;
}
return false;
}
}
2016-11-19 05:22:44 +00:00
POLYBAR_NS_END