mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Allow formatting memory with used and available memory (#334)
Allow formatting memory with used and available memory
This commit is contained in:
commit
7b11283b73
@ -16,9 +16,14 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
parseMeminfo();
|
parseMeminfo();
|
||||||
if (memtotal_ > 0 && memfree_ >= 0) {
|
if (memtotal_ > 0 && memfree_ >= 0) {
|
||||||
int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
|
int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
|
||||||
getState(used_ram_percentage);
|
|
||||||
label_.set_markup(fmt::format(format_, used_ram_percentage));
|
|
||||||
auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
|
auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
|
||||||
|
auto available_ram_gigabytes = memfree_ / std::pow(1024, 2);
|
||||||
|
|
||||||
|
getState(used_ram_percentage);
|
||||||
|
label_.set_markup(fmt::format(format_, used_ram_percentage,
|
||||||
|
fmt::arg("percentage", used_ram_percentage),
|
||||||
|
fmt::arg("used", used_ram_gigabytes),
|
||||||
|
fmt::arg("avail", available_ram_gigabytes)));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(fmt::format("{:.{}f}Gb used", used_ram_gigabytes, 1));
|
label_.set_tooltip_text(fmt::format("{:.{}f}Gb used", used_ram_gigabytes, 1));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user