Merge pull request #1705 from lbartoletti/freebsd_temperature_use_thermal-zone_config
This commit is contained in:
commit
debbfccf07
|
@ -3,10 +3,7 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
// clang-format off
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
// clang-format on
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
|
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
|
||||||
|
@ -80,6 +77,9 @@ float waybar::modules::Temperature::getTemperature() {
|
||||||
int temp;
|
int temp;
|
||||||
size_t size = sizeof 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) {
|
if (sysctlbyname("hw.acpi.thermal.tz0.temperature", &temp, &size, NULL, 0) != 0) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"sysctl hw.acpi.thermal.tz0.temperature or dev.cpu.0.temperature failed");
|
"sysctl hw.acpi.thermal.tz0.temperature or dev.cpu.0.temperature failed");
|
||||||
|
|
Loading…
Reference in New Issue