Fixed cpu module: Provide stub implementation for parseCpuFrequencies

This commit is contained in:
Mann mit Hut 2023-09-13 23:12:35 +02:00
parent 91b6629103
commit d5203e5b37
No known key found for this signature in database
GPG Key ID: 02D4D60B8250CB8C
3 changed files with 19 additions and 0 deletions

View File

@ -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',

View File

@ -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]);
}

View File

@ -0,0 +1,15 @@
#include <spdlog/spdlog.h>
#include <cmath> // NAN
#include "modules/cpu_frequency.hpp"
std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
static std::vector<float> frequencies;
if (frequencies.empty()) {
spdlog::warn(
"cpu/bsd: parseCpuFrequencies is not implemented, expect garbage in {*_frequency}");
frequencies.push_back(NAN);
}
return frequencies;
}