Merge branch 'master' into feat/first-day-of-week-calendar
This commit is contained in:
@@ -92,6 +92,12 @@ The *cpu* module displays the current CPU utilization.
|
|||||||
|
|
||||||
*{load}*: Current CPU load.
|
*{load}*: Current CPU load.
|
||||||
|
|
||||||
|
*{load1}*: CPU load average over the last minute.
|
||||||
|
|
||||||
|
*{load5}*: CPU load average over the last 5 minutes.
|
||||||
|
|
||||||
|
*{load15}*: CPU load average over the last 15 minutes.
|
||||||
|
|
||||||
*{usage}*: Current overall CPU usage.
|
*{usage}*: Current overall CPU usage.
|
||||||
|
|
||||||
*{usage*{n}*}*: Current CPU core n usage. Cores are numbered from zero, so first core will be {usage0} and 4th will be {usage3}.
|
*{usage*{n}*}*: Current CPU core n usage. Cores are numbered from zero, so first core will be {usage0} and 4th will be {usage3}.
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ Addressed by *temperature*
|
|||||||
The path of the hwmon-directory of the device, e.g. */sys/devices/pci0000:00/0000:00:18.3/hwmon*. (Note that the subdirectory *hwmon/hwmon#*, where *#* is a number is not part of the path!) Has to be used together with *input-filename*.
|
The path of the hwmon-directory of the device, e.g. */sys/devices/pci0000:00/0000:00:18.3/hwmon*. (Note that the subdirectory *hwmon/hwmon#*, where *#* is a number is not part of the path!) Has to be used together with *input-filename*.
|
||||||
This can also be an array of strings, for which, it just works like *hwmon-path*.
|
This can also be an array of strings, for which, it just works like *hwmon-path*.
|
||||||
|
|
||||||
|
*hwmon-name*: ++
|
||||||
|
typeof: string ++
|
||||||
|
Select a hwmon device by its name (from /sys/class/hwmon/\*/name), e.g. *amdgpu*.
|
||||||
|
Requires *input-filename* to be set.
|
||||||
|
Cannot be used together with *hwmon-path* or *hwmon-path-abs*.
|
||||||
|
|
||||||
*input-filename*: ++
|
*input-filename*: ++
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input*
|
The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input*
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
auto icons = std::vector<std::string>{state};
|
auto icons = std::vector<std::string>{state};
|
||||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(fmt::arg("load", load1));
|
store.push_back(fmt::arg("load", load1));
|
||||||
|
store.push_back(fmt::arg("load1", load1));
|
||||||
|
store.push_back(fmt::arg("load5", load5));
|
||||||
|
store.push_back(fmt::arg("load15", load15));
|
||||||
store.push_back(fmt::arg("usage", total_usage));
|
store.push_back(fmt::arg("usage", total_usage));
|
||||||
store.push_back(fmt::arg("icon", getIcon(total_usage, icons)));
|
store.push_back(fmt::arg("icon", getIcon(total_usage, icons)));
|
||||||
store.push_back(fmt::arg("max_frequency", max_frequency));
|
store.push_back(fmt::arg("max_frequency", max_frequency));
|
||||||
|
|||||||
@@ -20,6 +20,24 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
|
|||||||
if (check_set_path(item.asString())) break;
|
if (check_set_path(item.asString())) break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto find_hwmon_by_name = [](const std::string& name) -> std::optional<std::filesystem::path> {
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator("/sys/class/hwmon")) {
|
||||||
|
std::ifstream f(entry.path() / "name");
|
||||||
|
std::string hwname;
|
||||||
|
if (f >> hwname && hwname == name) {
|
||||||
|
return entry.path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ensure either hwmon-name OR old paths are used, not both
|
||||||
|
if (config_["hwmon-name"].isString() &&
|
||||||
|
(!config_["hwmon-path"].isNull() || !config_["hwmon-path-abs"].isNull())) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"hwmon-name cannot be used together with hwmon-path or hwmon-path-abs");
|
||||||
|
}
|
||||||
|
|
||||||
// if hwmon_path is an array, loop to find first valid item
|
// if hwmon_path is an array, loop to find first valid item
|
||||||
traverseAsArray(config_["hwmon-path"], [this](const std::string& path) {
|
traverseAsArray(config_["hwmon-path"], [this](const std::string& path) {
|
||||||
if (!std::filesystem::exists(path)) return false;
|
if (!std::filesystem::exists(path)) return false;
|
||||||
@@ -40,6 +58,20 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_path_.empty() && config_["hwmon-name"].isString()) {
|
||||||
|
if (!config_["input-filename"].isString()) {
|
||||||
|
throw std::runtime_error("hwmon-name requires input-filename to be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hwmon = find_hwmon_by_name(config_["hwmon-name"].asString());
|
||||||
|
|
||||||
|
if (!hwmon) {
|
||||||
|
throw std::runtime_error("hwmon-name '" + config_["hwmon-name"].asString() + "' not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
file_path_ = hwmon->string() + "/" + config_["input-filename"].asString();
|
||||||
|
}
|
||||||
|
|
||||||
if (file_path_.empty()) {
|
if (file_path_.empty()) {
|
||||||
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||||
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
|
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
|
||||||
|
|||||||
Reference in New Issue
Block a user