@@ -114,13 +114,17 @@ float waybar::modules::Temperature::getTemperature() {
114
114
115
115
auto zone = config_[" thermal-zone" ].isInt () ? config_[" thermal-zone" ].asInt () : 0 ;
116
116
117
- if (sysctlbyname (fmt::format (" hw.acpi.thermal.tz{}.temperature" , zone).c_str (), &temp, &size,
118
- NULL , 0 ) != 0 ) {
119
- throw std::runtime_error (fmt::format (
120
- " sysctl hw.acpi.thermal.tz{}.temperature or dev.cpu.{}.temperature failed" , zone, zone));
117
+ // First, try with dev.cpu
118
+ if ( (sysctlbyname (fmt::format (" dev.cpu.{}.temperature" , zone).c_str (), &temp, &size,
119
+ NULL , 0 ) == 0 ) ||
120
+ (sysctlbyname (fmt::format (" hw.acpi.thermal.tz{}.temperature" , zone).c_str (), &temp, &size,
121
+ NULL , 0 ) == 0 ) ) {
122
+ auto temperature_c = ((float )temp - 2732 ) / 10 ;
123
+ return temperature_c;
121
124
}
122
- auto temperature_c = ((float )temp - 2732 ) / 10 ;
123
- return temperature_c;
125
+
126
+ throw std::runtime_error (fmt::format (
127
+ " sysctl hw.acpi.thermal.tz{}.temperature and dev.cpu.{}.temperature failed" , zone, zone));
124
128
125
129
#else // Linux
126
130
std::ifstream temp (file_path_);
@@ -148,4 +152,4 @@ bool waybar::modules::Temperature::isWarning(uint16_t temperature_c) {
148
152
bool waybar::modules::Temperature::isCritical (uint16_t temperature_c) {
149
153
return config_[" critical-threshold" ].isInt () &&
150
154
temperature_c >= config_[" critical-threshold" ].asInt ();
151
- }
155
+ }
0 commit comments