mirror of
https://github.com/rad4day/Waybar.git
synced 2025-09-18 16:32:32 +02:00
feat(config): format modules
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "modules/memory.hpp"
|
||||
#include <iostream>
|
||||
|
||||
waybar::modules::Memory::Memory()
|
||||
waybar::modules::Memory::Memory(Json::Value config)
|
||||
: _config(config)
|
||||
{
|
||||
_label.get_style_context()->add_class("memory");
|
||||
_thread = [this] {
|
||||
@@ -14,8 +15,9 @@ auto waybar::modules::Memory::update() -> void
|
||||
{
|
||||
struct sysinfo info;
|
||||
if (!sysinfo(&info)) {
|
||||
double available = (double)info.freeram / (double)info.totalram;
|
||||
_label.set_text(fmt::format("{:.{}f}% ", available * 100, 0));
|
||||
int available = ((double)info.freeram / (double)info.totalram) * 100;
|
||||
auto format = _config["format"] ? _config["format"].asString() : "{}%";
|
||||
_label.set_text(fmt::format(format, available));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user