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
2016-12-21 09:21:35 +01:00

30 lines
686 B
C++

#include "modules/counter.hpp"
#include "modules/meta/base.inl"
POLYBAR_NS
namespace modules {
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);
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
}
bool counter_module::update() {
m_counter++;
return true;
}
bool counter_module::build(builder* builder, const string& tag) const {
if (tag == TAG_COUNTER) {
builder->node(to_string(m_counter));
return true;
}
return false;
}
}
POLYBAR_NS_END