mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #2241 from yangyingchao/master
support multiple items in hwmon-path of temperature module
This commit is contained in:
@ -11,8 +11,18 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
|
||||
#if defined(__FreeBSD__)
|
||||
// try to read sysctl?
|
||||
#else
|
||||
if (config_["hwmon-path"].isString()) {
|
||||
file_path_ = config_["hwmon-path"].asString();
|
||||
auto& hwmon_path = config_["hwmon-path"];
|
||||
if (hwmon_path.isString()) {
|
||||
file_path_ = hwmon_path.asString();
|
||||
} else if (hwmon_path.isArray()) {
|
||||
// if hwmon_path is an array, loop to find first valid item
|
||||
for (auto& item : hwmon_path) {
|
||||
auto path = item.asString();
|
||||
if (std::filesystem::exists(path)) {
|
||||
file_path_ = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) {
|
||||
file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString()))
|
||||
.path()
|
||||
|
Reference in New Issue
Block a user