mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
[FreeBSD] Use thermal-zone
The zone was hardcoded in #1702. This commit allows to use the "thermal-zone" variable. Follow up #1702
This commit is contained in:
parent
5da45ece9d
commit
c3e91cd228
@ -81,8 +81,11 @@ float waybar::modules::Temperature::getTemperature() {
|
|||||||
int temp;
|
int temp;
|
||||||
size_t size = sizeof temp;
|
size_t size = sizeof temp;
|
||||||
|
|
||||||
if (sysctlbyname("hw.acpi.thermal.tz0.temperature", &temp, &size, NULL, 0) != 0) {
|
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||||
throw std::runtime_error("sysctl hw.acpi.thermal.tz0.temperature or dev.cpu.0.temperature failed");
|
auto sysctl_thermal = fmt::format("hw.acpi.thermal.tz{}.temperature", zone);
|
||||||
|
|
||||||
|
if (sysctlbyname(sysctl_thermal.c_str(), &temp, &size, NULL, 0) != 0) {
|
||||||
|
throw std::runtime_error(fmt::format("sysctl {} failed",sysctl_thermal));
|
||||||
}
|
}
|
||||||
auto temperature_c = ((float)temp-2732)/10;
|
auto temperature_c = ((float)temp-2732)/10;
|
||||||
return temperature_c;
|
return temperature_c;
|
||||||
|
Loading…
Reference in New Issue
Block a user