1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/src/modules/counter.cpp

31 lines
686 B
C++
Raw Normal View History

2016-11-02 15:22:45 -04:00
#include "modules/counter.hpp"
2016-11-20 17:04:31 -05:00
#include "modules/meta/base.inl"
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-11-02 15:22:45 -04:00
namespace modules {
2016-11-20 17:04:31 -05: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 15:22:45 -04:00
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
}
bool counter_module::update() {
m_counter++;
return true;
}
2016-11-25 07:55:15 -05:00
bool counter_module::build(builder* builder, const string& tag) const {
2016-11-02 15:22:45 -04:00
if (tag == TAG_COUNTER) {
builder->node(to_string(m_counter));
return true;
}
return false;
}
}
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END