fix(FreeBSD): Use dev.cpu temperature sysctl
This commit is contained in:
@ -114,13 +114,17 @@ float waybar::modules::Temperature::getTemperature() {
|
|||||||
|
|
||||||
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||||
|
|
||||||
if (sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
|
// First, try with dev.cpu
|
||||||
NULL, 0) != 0) {
|
if ( (sysctlbyname(fmt::format("dev.cpu.{}.temperature", zone).c_str(), &temp, &size,
|
||||||
throw std::runtime_error(fmt::format(
|
NULL, 0) == 0) ||
|
||||||
"sysctl hw.acpi.thermal.tz{}.temperature or dev.cpu.{}.temperature failed", zone, zone));
|
(sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
|
||||||
|
NULL, 0) == 0) ) {
|
||||||
|
auto temperature_c = ((float)temp - 2732) / 10;
|
||||||
|
return temperature_c;
|
||||||
}
|
}
|
||||||
auto temperature_c = ((float)temp - 2732) / 10;
|
|
||||||
return temperature_c;
|
throw std::runtime_error(fmt::format(
|
||||||
|
"sysctl hw.acpi.thermal.tz{}.temperature and dev.cpu.{}.temperature failed", zone, zone));
|
||||||
|
|
||||||
#else // Linux
|
#else // Linux
|
||||||
std::ifstream temp(file_path_);
|
std::ifstream temp(file_path_);
|
||||||
|
Reference in New Issue
Block a user