mirror of https://github.com/polybar/polybar.git
parent
0fd614b0a9
commit
2f62a6fbad
|
@ -19,12 +19,16 @@ namespace modules {
|
||||||
static constexpr const char* TAG_LABEL{"<label>"};
|
static constexpr const char* TAG_LABEL{"<label>"};
|
||||||
static constexpr const char* TAG_BAR_USED{"<bar-used>"};
|
static constexpr const char* TAG_BAR_USED{"<bar-used>"};
|
||||||
static constexpr const char* TAG_BAR_FREE{"<bar-free>"};
|
static constexpr const char* TAG_BAR_FREE{"<bar-free>"};
|
||||||
|
static constexpr const char* TAG_RAMP_USED{"<ramp-used>"};
|
||||||
|
static constexpr const char* TAG_RAMP_FREE{"<ramp-free>"};
|
||||||
|
|
||||||
label_t m_label;
|
label_t m_label;
|
||||||
progressbar_t m_bar_memused;
|
progressbar_t m_bar_memused;
|
||||||
progressbar_t m_bar_memfree;
|
progressbar_t m_bar_memfree;
|
||||||
int m_perc_memused{0};
|
int m_perc_memused{0};
|
||||||
int m_perc_memfree{0};
|
int m_perc_memfree{0};
|
||||||
|
ramp_t m_ramp_memused;
|
||||||
|
ramp_t m_ramp_memfree;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "drawtypes/label.hpp"
|
#include "drawtypes/label.hpp"
|
||||||
#include "drawtypes/progressbar.hpp"
|
#include "drawtypes/progressbar.hpp"
|
||||||
|
#include "drawtypes/ramp.hpp"
|
||||||
#include "modules/memory.hpp"
|
#include "modules/memory.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ namespace modules {
|
||||||
memory_module::memory_module(const bar_settings& bar, string name_) : timer_module<memory_module>(bar, move(name_)) {
|
memory_module::memory_module(const bar_settings& bar, string name_) : timer_module<memory_module>(bar, move(name_)) {
|
||||||
m_interval = m_conf.get<decltype(m_interval)>(name(), "interval", 1s);
|
m_interval = m_conf.get<decltype(m_interval)>(name(), "interval", 1s);
|
||||||
|
|
||||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE});
|
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE, TAG_RAMP_USED, TAG_RAMP_FREE});
|
||||||
|
|
||||||
if (m_formatter->has(TAG_BAR_USED)) {
|
if (m_formatter->has(TAG_BAR_USED)) {
|
||||||
m_bar_memused = load_progressbar(m_bar, m_conf, name(), TAG_BAR_USED);
|
m_bar_memused = load_progressbar(m_bar, m_conf, name(), TAG_BAR_USED);
|
||||||
|
@ -25,6 +26,12 @@ namespace modules {
|
||||||
if (m_formatter->has(TAG_BAR_FREE)) {
|
if (m_formatter->has(TAG_BAR_FREE)) {
|
||||||
m_bar_memfree = load_progressbar(m_bar, m_conf, name(), TAG_BAR_FREE);
|
m_bar_memfree = load_progressbar(m_bar, m_conf, name(), TAG_BAR_FREE);
|
||||||
}
|
}
|
||||||
|
if(m_formatter->has(TAG_RAMP_USED)) {
|
||||||
|
m_ramp_memused = load_ramp(m_conf, name(), TAG_RAMP_USED);
|
||||||
|
}
|
||||||
|
if(m_formatter->has(TAG_RAMP_FREE)) {
|
||||||
|
m_ramp_memfree = load_ramp(m_conf, name(), TAG_RAMP_FREE);
|
||||||
|
}
|
||||||
if (m_formatter->has(TAG_LABEL)) {
|
if (m_formatter->has(TAG_LABEL)) {
|
||||||
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%percentage_used%%");
|
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%percentage_used%%");
|
||||||
}
|
}
|
||||||
|
@ -91,6 +98,10 @@ namespace modules {
|
||||||
builder->node(m_bar_memfree->output(m_perc_memfree));
|
builder->node(m_bar_memfree->output(m_perc_memfree));
|
||||||
} else if (tag == TAG_LABEL) {
|
} else if (tag == TAG_LABEL) {
|
||||||
builder->node(m_label);
|
builder->node(m_label);
|
||||||
|
} else if (tag == TAG_RAMP_FREE) {
|
||||||
|
builder->node(m_ramp_memfree->get_by_percentage(m_perc_memfree));
|
||||||
|
} else if (tag == TAG_RAMP_USED) {
|
||||||
|
builder->node(m_ramp_memused->get_by_percentage(m_perc_memused));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue