mirror of
https://github.com/polybar/polybar.git
synced 2024-11-18 13:55:11 -05:00
feat(mem): Add ramp and bar for swap (#1325)
Now all the tokens in the memory module also have ramp and bar counterparts. These can be used exactly the same as `bar-used` and `ramp-used`, they are named `<bar-swap-used>`, `<bar-swap-free>`, `<ramp-swap-used>`, and `<ramp-swap-free>`
This commit is contained in:
parent
a2ab4699ab
commit
11d66ee78d
2 changed files with 31 additions and 1 deletions
|
@ -21,6 +21,10 @@ namespace modules {
|
||||||
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_USED{"<ramp-used>"};
|
||||||
static constexpr const char* TAG_RAMP_FREE{"<ramp-free>"};
|
static constexpr const char* TAG_RAMP_FREE{"<ramp-free>"};
|
||||||
|
static constexpr const char* TAG_BAR_SWAP_USED{"<bar-swap-used>"};
|
||||||
|
static constexpr const char* TAG_BAR_SWAP_FREE{"<bar-swap-free>"};
|
||||||
|
static constexpr const char* TAG_RAMP_SWAP_USED{"<ramp-swap-used>"};
|
||||||
|
static constexpr const char* TAG_RAMP_SWAP_FREE{"<ramp-swap-free>"};
|
||||||
|
|
||||||
label_t m_label;
|
label_t m_label;
|
||||||
progressbar_t m_bar_memused;
|
progressbar_t m_bar_memused;
|
||||||
|
@ -29,8 +33,12 @@ namespace modules {
|
||||||
int m_perc_memfree{0};
|
int m_perc_memfree{0};
|
||||||
ramp_t m_ramp_memused;
|
ramp_t m_ramp_memused;
|
||||||
ramp_t m_ramp_memfree;
|
ramp_t m_ramp_memfree;
|
||||||
|
progressbar_t m_bar_swapused;
|
||||||
|
progressbar_t m_bar_swapfree;
|
||||||
int m_perc_swap_used{0};
|
int m_perc_swap_used{0};
|
||||||
int m_perc_swap_free{0};
|
int m_perc_swap_free{0};
|
||||||
|
ramp_t m_ramp_swapused;
|
||||||
|
ramp_t m_ramp_swapfree;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ 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, TAG_RAMP_USED, TAG_RAMP_FREE});
|
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE, TAG_RAMP_USED, TAG_RAMP_FREE,
|
||||||
|
TAG_BAR_SWAP_USED, TAG_BAR_SWAP_FREE, TAG_RAMP_SWAP_USED, TAG_RAMP_SWAP_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);
|
||||||
|
@ -32,6 +33,19 @@ namespace modules {
|
||||||
if(m_formatter->has(TAG_RAMP_FREE)) {
|
if(m_formatter->has(TAG_RAMP_FREE)) {
|
||||||
m_ramp_memfree = load_ramp(m_conf, name(), TAG_RAMP_FREE);
|
m_ramp_memfree = load_ramp(m_conf, name(), TAG_RAMP_FREE);
|
||||||
}
|
}
|
||||||
|
if (m_formatter->has(TAG_BAR_SWAP_USED)) {
|
||||||
|
m_bar_swapused = load_progressbar(m_bar, m_conf, name(), TAG_BAR_SWAP_USED);
|
||||||
|
}
|
||||||
|
if (m_formatter->has(TAG_BAR_SWAP_FREE)) {
|
||||||
|
m_bar_swapfree = load_progressbar(m_bar, m_conf, name(), TAG_BAR_SWAP_FREE);
|
||||||
|
}
|
||||||
|
if(m_formatter->has(TAG_RAMP_SWAP_USED)) {
|
||||||
|
m_ramp_swapused = load_ramp(m_conf, name(), TAG_RAMP_SWAP_USED);
|
||||||
|
}
|
||||||
|
if(m_formatter->has(TAG_RAMP_SWAP_FREE)) {
|
||||||
|
m_ramp_swapfree = load_ramp(m_conf, name(), TAG_RAMP_SWAP_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%%");
|
||||||
}
|
}
|
||||||
|
@ -116,6 +130,14 @@ namespace modules {
|
||||||
builder->node(m_ramp_memfree->get_by_percentage(m_perc_memfree));
|
builder->node(m_ramp_memfree->get_by_percentage(m_perc_memfree));
|
||||||
} else if (tag == TAG_RAMP_USED) {
|
} else if (tag == TAG_RAMP_USED) {
|
||||||
builder->node(m_ramp_memused->get_by_percentage(m_perc_memused));
|
builder->node(m_ramp_memused->get_by_percentage(m_perc_memused));
|
||||||
|
} else if (tag == TAG_BAR_SWAP_USED) {
|
||||||
|
builder->node(m_bar_swapused->output(m_perc_swap_used));
|
||||||
|
} else if (tag == TAG_BAR_SWAP_FREE) {
|
||||||
|
builder->node(m_bar_swapfree->output(m_perc_swap_free));
|
||||||
|
} else if (tag == TAG_RAMP_SWAP_FREE) {
|
||||||
|
builder->node(m_ramp_swapfree->get_by_percentage(m_perc_swap_free));
|
||||||
|
} else if (tag == TAG_RAMP_SWAP_USED) {
|
||||||
|
builder->node(m_ramp_swapused->get_by_percentage(m_perc_swap_used));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue