1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00
polybar/include/modules/counter.hpp
Michael Carlberg 68f72d69cc refactor: Drop tokenized labels
Handle placeholder tokens inside each label
instead of cloning into a new instance each time
2016-10-19 01:31:17 +02:00

39 lines
765 B
C++

#pragma once
#include "modules/meta.hpp"
LEMONBUDDY_NS
using namespace drawtypes;
namespace modules {
class counter_module : public timer_module<counter_module> {
public:
using timer_module::timer_module;
void setup() {
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
}
bool update() {
m_counter++;
return true;
}
bool build(builder* builder, string tag) const {
if (tag == TAG_COUNTER) {
builder->node(to_string(m_counter));
return true;
}
return false;
}
private:
static constexpr auto TAG_COUNTER = "<counter>";
int m_counter{0};
};
}
LEMONBUDDY_NS_END