2018-08-08 23:42:52 +00:00
|
|
|
#include "modules/memory.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
waybar::modules::Memory::Memory()
|
|
|
|
{
|
2018-08-09 08:50:16 +00:00
|
|
|
_label.get_style_context()->add_class("memory");
|
2018-08-08 23:42:52 +00:00
|
|
|
_thread = [this] {
|
|
|
|
struct sysinfo info;
|
|
|
|
if (!sysinfo(&info)) {
|
|
|
|
double available = (double)info.freeram / (double)info.totalram;
|
2018-08-09 08:50:16 +00:00
|
|
|
_label.set_text(fmt::format("{:.{}f}% ", available * 100, 0));
|
2018-08-08 23:42:52 +00:00
|
|
|
}
|
|
|
|
_thread.sleep_for(chrono::seconds(30));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
waybar::modules::Memory::operator Gtk::Widget &() {
|
|
|
|
return _label;
|
|
|
|
}
|