feat: add pulseaudio module

This commit is contained in:
Alexis
2018-08-09 23:55:38 +02:00
parent 11fab436b9
commit 7ccb76935d
9 changed files with 167 additions and 19 deletions

View File

@@ -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));
}
}