mirror of
https://github.com/polybar/polybar.git
synced 2024-11-11 13:50:56 -05:00
68f72d69cc
Handle placeholder tokens inside each label instead of cloning into a new instance each time
39 lines
765 B
C++
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
|