feat: memory module

This commit is contained in:
Alexis
2018-08-09 01:42:52 +02:00
parent 81b5c37d86
commit 17fc77cb5e
4 changed files with 53 additions and 2 deletions

20
src/modules/memory.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "modules/memory.hpp"
#include <iostream>
waybar::modules::Memory::Memory()
{
_label.get_style_context()->add_class("memory-widget");
_thread = [this] {
struct sysinfo info;
if (!sysinfo(&info)) {
double available = (double)info.freeram / (double)info.totalram;
std::cout << available << std::endl;
_label.set_text(fmt::format("{:.{}f}% ", available * 100, 1));
}
_thread.sleep_for(chrono::seconds(30));
};
};
waybar::modules::Memory::operator Gtk::Widget &() {
return _label;
}