From 2f975f870a715f6691ebd2fc12d6ad75dc752316 Mon Sep 17 00:00:00 2001 From: BoostCookie Date: Thu, 12 Mar 2020 22:04:00 +0100 Subject: [PATCH] Added support for absolute device paths for the temperature module. --- man/waybar-temperature.5.scd | 8 ++++++++ src/modules/temperature.cpp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index f8676867..eeae5462 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -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). diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 78391a0d..f2dd9587 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -1,9 +1,12 @@ #include "modules/temperature.hpp" +#include 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);