Merge pull request #624 from BoostCookie/master
Added support for absolute device paths for the temperature module.pull/634/head
commit
5db06d99bb
|
@ -20,6 +20,14 @@ Addressed by *temperature*
|
|||
typeof: string ++
|
||||
The temperature path to use, e.g. */sys/class/hwmon/hwmon2/temp1_input* instead of one in */sys/class/thermal/*.
|
||||
|
||||
*hwmon-path-abs*: ++
|
||||
typeof: string ++
|
||||
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*.
|
||||
|
||||
*input-filename*: ++
|
||||
typeof: string ++
|
||||
The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input*
|
||||
|
||||
*critical-threshold*: ++
|
||||
typeof: integer ++
|
||||
The threshold before it is considered critical (Celsius).
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#include "modules/temperature.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "temperature", id, "{temperatureC}°C", 10) {
|
||||
if (config_["hwmon-path"].isString()) {
|
||||
file_path_ = config_["hwmon-path"].asString();
|
||||
} else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) {
|
||||
file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString())).path().u8string() + "/" + config_["input-filename"].asString();
|
||||
} else {
|
||||
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
|
||||
|
|
Loading…
Reference in New Issue