support format-icon for cpu und memory

This commit is contained in:
Tobias Bengfort 2021-08-23 07:30:07 +02:00
parent ab38f13052
commit 7b4b5e55a2
4 changed files with 14 additions and 0 deletions

View File

@ -20,6 +20,11 @@ The *cpu* module displays the current cpu utilization.
default: {usage}% ++ default: {usage}% ++
The format, how information should be displayed. On {} data gets inserted. The format, how information should be displayed. On {} data gets inserted.
*format-icons*: ++
typeof: array/object ++
Based on the current usage, the corresponding icon gets selected. ++
The order is *low* to *high*. Or by the state if it is an object.
*max-length*: ++ *max-length*: ++
typeof: integer ++ typeof: integer ++
The maximum length in character the module should display. The maximum length in character the module should display.

View File

@ -22,6 +22,11 @@ Addressed by *memory*
default: {percentage}% ++ default: {percentage}% ++
The format, how information should be displayed. The format, how information should be displayed.
*format-icons*: ++
typeof: array/object ++
Based on the current percentage, the corresponding icon gets selected. ++
The order is *low* to *high*. Or by the state if it is an object.
*rotate*: ++ *rotate*: ++
typeof: integer ++ typeof: integer ++
Positive value to rotate the text label. Positive value to rotate the text label.

View File

@ -26,9 +26,11 @@ auto waybar::modules::Cpu::update() -> void {
event_box_.hide(); event_box_.hide();
} else { } else {
event_box_.show(); event_box_.show();
auto icons = std::vector<std::string>{state};
label_.set_markup(fmt::format(format, label_.set_markup(fmt::format(format,
fmt::arg("load", cpu_load), fmt::arg("load", cpu_load),
fmt::arg("usage", cpu_usage), fmt::arg("usage", cpu_usage),
fmt::arg("icon", getIcon(cpu_usage, icons)),
fmt::arg("max_frequency", max_frequency), fmt::arg("max_frequency", max_frequency),
fmt::arg("min_frequency", min_frequency), fmt::arg("min_frequency", min_frequency),
fmt::arg("avg_frequency", avg_frequency))); fmt::arg("avg_frequency", avg_frequency)));

View File

@ -38,8 +38,10 @@ auto waybar::modules::Memory::update() -> void {
event_box_.hide(); event_box_.hide();
} else { } else {
event_box_.show(); event_box_.show();
auto icons = std::vector<std::string>{state};
label_.set_markup(fmt::format(format, label_.set_markup(fmt::format(format,
used_ram_percentage, used_ram_percentage,
fmt::arg("icon", getIcon(used_ram_percentage, icons)),
fmt::arg("total", total_ram_gigabytes), fmt::arg("total", total_ram_gigabytes),
fmt::arg("percentage", used_ram_percentage), fmt::arg("percentage", used_ram_percentage),
fmt::arg("used", used_ram_gigabytes), fmt::arg("used", used_ram_gigabytes),