Merge pull request #1705 from lbartoletti/freebsd_temperature_use_thermal-zone_config

This commit is contained in:
Alex 2022-10-17 09:52:54 +02:00 committed by GitHub
commit debbfccf07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,7 @@
#include <filesystem>
#if defined(__FreeBSD__)
// clang-format off
#include <sys/types.h>
#include <sys/sysctl.h>
// clang-format on
#endif
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
@ -80,6 +77,9 @@ float waybar::modules::Temperature::getTemperature() {
int temp;
size_t size = sizeof temp;
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
auto sysctl_thermal = fmt::format("hw.acpi.thermal.tz{}.temperature", zone);
if (sysctlbyname("hw.acpi.thermal.tz0.temperature", &temp, &size, NULL, 0) != 0) {
throw std::runtime_error(
"sysctl hw.acpi.thermal.tz0.temperature or dev.cpu.0.temperature failed");