disk module: add state for percentage_used

This commit is contained in:
Thorben Günther 2020-09-21 13:17:11 +02:00
parent 6db795401a
commit 12016d35bb
No known key found for this signature in database
GPG Key ID: 415CD778D8C5AFED
2 changed files with 8 additions and 2 deletions

View File

@ -31,6 +31,10 @@ Addressed by *disk*
typeof: integer ++ typeof: integer ++
Positive value to rotate the text label. Positive value to rotate the text label.
*states*: ++
typeof: array ++
A number of disk utilization states which get activated on certain percentage thresholds (percentage_used). See *waybar-states(5)*.
*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

@ -47,13 +47,14 @@ auto waybar::modules::Disk::update() -> void {
auto free = pow_format(stats.f_bavail * stats.f_frsize, "B", true); auto free = pow_format(stats.f_bavail * stats.f_frsize, "B", true);
auto used = pow_format((stats.f_blocks - stats.f_bavail) * stats.f_frsize, "B", true); auto used = pow_format((stats.f_blocks - stats.f_bavail) * stats.f_frsize, "B", true);
auto total = pow_format(stats.f_blocks * stats.f_frsize, "B", true); auto total = pow_format(stats.f_blocks * stats.f_frsize, "B", true);
auto percentage_used = (stats.f_blocks - stats.f_bavail) * 100 / stats.f_blocks;
label_.set_markup(fmt::format(format_ label_.set_markup(fmt::format(format_
, stats.f_bavail * 100 / stats.f_blocks , stats.f_bavail * 100 / stats.f_blocks
, fmt::arg("free", free) , fmt::arg("free", free)
, fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks) , fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks)
, fmt::arg("used", used) , fmt::arg("used", used)
, fmt::arg("percentage_used", (stats.f_blocks - stats.f_bavail) * 100 / stats.f_blocks) , fmt::arg("percentage_used", percentage_used)
, fmt::arg("total", total) , fmt::arg("total", total)
, fmt::arg("path", path_) , fmt::arg("path", path_)
)); ));
@ -67,12 +68,13 @@ auto waybar::modules::Disk::update() -> void {
, fmt::arg("free", free) , fmt::arg("free", free)
, fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks) , fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks)
, fmt::arg("used", used) , fmt::arg("used", used)
, fmt::arg("percentage_used", (stats.f_blocks - stats.f_bavail) * 100 / stats.f_blocks) , fmt::arg("percentage_used", percentage_used)
, fmt::arg("total", total) , fmt::arg("total", total)
, fmt::arg("path", path_) , fmt::arg("path", path_)
)); ));
} }
event_box_.show(); event_box_.show();
getState(percentage_used);
// Call parent update // Call parent update
ALabel::update(); ALabel::update();
} }