Skip to content

Commit

Permalink
Merge pull request #2888 from imran1008/hwmon-path-abs-subdir
Browse files Browse the repository at this point in the history
Search for the first hwmon* directory
  • Loading branch information
Alexays authored Feb 19, 2024
2 parents 9191cae + 9287571 commit 6fbae3b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/modules/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
}
}
} else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) {
file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString()))
.path()
.string() +
"/" + config_["input-filename"].asString();
} else {
for (const auto& hwmon : std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString())) {
if (hwmon.path().filename().string().starts_with("hwmon")) {
file_path_ = hwmon.path().string() + "/" + config_["input-filename"].asString();
break;
}
}
}

if (file_path_.empty()) {
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
}
Expand Down

0 comments on commit 6fbae3b

Please sign in to comment.