diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp index 3b6342b3..b03a6349 100644 --- a/include/modules/memory.hpp +++ b/include/modules/memory.hpp @@ -1,8 +1,5 @@ #pragma once -#include - -#include #include #include "ALabel.hpp" diff --git a/meson.build b/meson.build index d587204d..9ea8a75e 100644 --- a/meson.build +++ b/meson.build @@ -187,14 +187,18 @@ inc_dirs = ['include'] if is_linux add_project_arguments('-DHAVE_CPU_LINUX', language: 'cpp') + add_project_arguments('-DHAVE_MEMORY_LINUX', language: 'cpp') src_files += files('src/modules/battery.cpp', 'src/modules/cpu.cpp', 'src/modules/cpu_frequency/common.cpp', 'src/modules/cpu_frequency/linux.cpp', 'src/modules/cpu_usage/common.cpp', - 'src/modules/cpu_usage/linux.cpp') + 'src/modules/cpu_usage/linux.cpp', + 'src/modules/memory/common.cpp', + 'src/modules/memory/linux.cpp') man_files += files('man/waybar-battery.5.scd', - 'man/waybar-cpu.5.scd') + 'man/waybar-cpu.5.scd', + 'man/waybar-memory.5.scd') elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd add_project_arguments('-DHAVE_CPU_BSD', language: 'cpp') add_project_arguments('-DHAVE_MEMORY_BSD', language: 'cpp') @@ -205,13 +209,13 @@ elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd 'src/modules/cpu_frequency/common.cpp', 'src/modules/cpu_usage/bsd.cpp', 'src/modules/cpu_usage/common.cpp', -# 'src/modules/memory/bsd.cpp', -# 'src/modules/memory/common.cpp', + 'src/modules/memory/bsd.cpp', + 'src/modules/memory/common.cpp', ) man_files += files( # 'man/waybar-cffi.5.scd', 'man/waybar-cpu.5.scd', -# 'man/waybar-memory.5.scd', + 'man/waybar-memory.5.scd' ) if is_freebsd src_files += files('src/modules/battery.cpp') diff --git a/src/factory.cpp b/src/factory.cpp index 5b32bd4e..708a82bb 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -204,12 +204,12 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name, #endif if (ref == "idle_inhibitor") { return new waybar::modules::IdleInhibitor(id, bar_, config_[name]); - } + }*/ #if defined(HAVE_MEMORY_LINUX) || defined(HAVE_MEMORY_BSD) if (ref == "memory") { return new waybar::modules::Memory(id, config_[name]); } -#endif*/ +#endif #if defined(HAVE_CPU_LINUX) || defined(HAVE_CPU_BSD) if (ref == "cpu") { return new waybar::modules::Cpu(id, config_[name]); diff --git a/src/modules/memory/common.cpp b/src/modules/memory/common.cpp index 544d7814..f46c1374 100644 --- a/src/modules/memory/common.cpp +++ b/src/modules/memory/common.cpp @@ -1,5 +1,7 @@ #include "modules/memory.hpp" +#include + waybar::modules::Memory::Memory(const std::string& id, const Json::Value& config) : ALabel(config, "memory", id, "{}%", 30) { thread_ = [this] { @@ -51,11 +53,11 @@ auto waybar::modules::Memory::update() -> void { } if (format.empty()) { - event_box_.hide(); + Gtk::Label::hide(); } else { - event_box_.show(); + Gtk::Label::show(); auto icons = std::vector{state}; - label_.set_markup(fmt::format( + Gtk::Label::set_markup(fmt::format( fmt::runtime(format), used_ram_percentage, fmt::arg("icon", getIcon(used_ram_percentage, icons)), fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes), @@ -68,7 +70,7 @@ auto waybar::modules::Memory::update() -> void { if (tooltipEnabled()) { if (config_["tooltip-format"].isString()) { auto tooltip_format = config_["tooltip-format"].asString(); - label_.set_tooltip_text(fmt::format( + Gtk::Label::set_tooltip_text(fmt::format( fmt::runtime(tooltip_format), used_ram_percentage, fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes), fmt::arg("percentage", used_ram_percentage), @@ -76,11 +78,11 @@ auto waybar::modules::Memory::update() -> void { fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes), fmt::arg("swapAvail", available_swap_gigabytes))); } else { - label_.set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1)); + Gtk::Label::set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1)); } } } else { - event_box_.hide(); + Gtk::Label::hide(); } // Call parent update ALabel::update(); diff --git a/src/modules/memory/linux.cpp b/src/modules/memory/linux.cpp index 50f50d6f..0fe07cb8 100644 --- a/src/modules/memory/linux.cpp +++ b/src/modules/memory/linux.cpp @@ -1,5 +1,7 @@ #include "modules/memory.hpp" +#include + static unsigned zfsArcSize() { std::ifstream zfs_arc_stats{"/proc/spl/kstat/zfs/arcstats"};