mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Added support for absolute device paths for the temperature module.
This commit is contained in:
parent
4471d4aba1
commit
2f975f870a
@ -20,6 +20,14 @@ Addressed by *temperature*
|
|||||||
typeof: string ++
|
typeof: string ++
|
||||||
The temperature path to use, e.g. */sys/class/hwmon/hwmon2/temp1_input* instead of one in */sys/class/thermal/*.
|
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*: ++
|
*critical-threshold*: ++
|
||||||
typeof: integer ++
|
typeof: integer ++
|
||||||
The threshold before it is considered critical (Celsius).
|
The threshold before it is considered critical (Celsius).
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#include "modules/temperature.hpp"
|
#include "modules/temperature.hpp"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
|
waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config)
|
||||||
: ALabel(config, "temperature", id, "{temperatureC}°C", 10) {
|
: ALabel(config, "temperature", id, "{temperatureC}°C", 10) {
|
||||||
if (config_["hwmon-path"].isString()) {
|
if (config_["hwmon-path"].isString()) {
|
||||||
file_path_ = config_["hwmon-path"].asString();
|
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 {
|
} else {
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user