mirror of
https://github.com/rad4day/Waybar.git
synced 2025-09-18 16:32:32 +02:00
feat: add pulseaudio module
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "modules/memory.hpp"
|
||||
#include <iostream>
|
||||
|
||||
waybar::modules::Memory::Memory(Json::Value config)
|
||||
: _config(config)
|
||||
@@ -16,10 +15,12 @@ auto waybar::modules::Memory::update() -> void
|
||||
{
|
||||
struct sysinfo info;
|
||||
if (!sysinfo(&info)) {
|
||||
int used_ram_percentage = 100 * (info.totalram - info.freeram) / info.totalram;
|
||||
auto total = info.totalram * info.mem_unit;
|
||||
auto freeram = info.freeram * info.mem_unit;
|
||||
int used_ram_percentage = 100 * (total - freeram) / total;
|
||||
auto format = _config["format"] ? _config["format"].asString() : "{}%";
|
||||
_label.set_text(fmt::format(format, used_ram_percentage));
|
||||
auto used_ram_gigabytes = (info.totalram - info.freeram) / std::pow(1024, 3);
|
||||
auto used_ram_gigabytes = (total - freeram) / std::pow(1024, 3);
|
||||
_label.set_tooltip_text(fmt::format("{:.{}f}Gb used", used_ram_gigabytes, 1));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user