From d5203e5b379077da262834f11fa30bfd6436c293 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 13 Sep 2023 23:12:35 +0200 Subject: [PATCH] Fixed cpu module: Provide stub implementation for parseCpuFrequencies --- meson.build | 2 ++ src/factory.cpp | 2 ++ src/modules/cpu_frequency/bsd.cpp | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 src/modules/cpu_frequency/bsd.cpp diff --git a/meson.build b/meson.build index f4af7c67..0dab053e 100644 --- a/meson.build +++ b/meson.build @@ -201,6 +201,8 @@ elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd add_project_arguments('-DHAVE_MEMORY_BSD', language: 'cpp') src_files += files( 'src/modules/cpu.cpp', + 'src/modules/cpu_frequency/bsd.cpp', + 'src/modules/cpu_frequency/common.cpp', 'src/modules/cpu_usage/bsd.cpp', 'src/modules/cpu_usage/common.cpp', 'src/modules/memory/bsd.cpp', diff --git a/src/factory.cpp b/src/factory.cpp index 18b14427..d9d09ed1 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -99,9 +99,11 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { if (ref == "cpu") { return new waybar::modules::Cpu(id, config_[name]); } +#if defined(HAVE_CPU_LINUX) if (ref == "cpu_frequency") { return new waybar::modules::CpuFrequency(id, config_[name]); } +#endif if (ref == "cpu_usage") { return new waybar::modules::CpuUsage(id, config_[name]); } diff --git a/src/modules/cpu_frequency/bsd.cpp b/src/modules/cpu_frequency/bsd.cpp new file mode 100644 index 00000000..8cbe4f85 --- /dev/null +++ b/src/modules/cpu_frequency/bsd.cpp @@ -0,0 +1,15 @@ +#include + +#include // NAN + +#include "modules/cpu_frequency.hpp" + +std::vector waybar::modules::CpuFrequency::parseCpuFrequencies() { + static std::vector frequencies; + if (frequencies.empty()) { + spdlog::warn( + "cpu/bsd: parseCpuFrequencies is not implemented, expect garbage in {*_frequency}"); + frequencies.push_back(NAN); + } + return frequencies; +}