feat(temperature): Add zone-type
setting (#2752)
Signed-off-by: xphoniex <dj.2dixx@gmail.com> Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
parent
708bd9c891
commit
6ccecbfca2
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- `custom/text`: Loads the `format` setting, which supports the `<label>` tag, if the deprecated `content` is not defined ([`#1331`](https://github.com/polybar/polybar/issues/1331), [`#2673`](https://github.com/polybar/polybar/pull/2673), [`#2676`](https://github.com/polybar/polybar/pull/2676))
|
- `custom/text`: Loads the `format` setting, which supports the `<label>` tag, if the deprecated `content` is not defined ([`#1331`](https://github.com/polybar/polybar/issues/1331), [`#2673`](https://github.com/polybar/polybar/pull/2673), [`#2676`](https://github.com/polybar/polybar/pull/2676))
|
||||||
- Added experimental support for positioning the tray like a module
|
- Added experimental support for positioning the tray like a module
|
||||||
- `internal/backlight`: `scroll-interval` option ([`#2696`](https://github.com/polybar/polybar/issues/2696), [`#2700`](https://github.com/polybar/polybar/pull/2700))
|
- `internal/backlight`: `scroll-interval` option ([`#2696`](https://github.com/polybar/polybar/issues/2696), [`#2700`](https://github.com/polybar/polybar/pull/2700))
|
||||||
|
- `internal/temperature`: Added `zone-type` setting ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2752`](https://github.com/polybar/polybar/pull/2752)) by [@xphoniex](https://github.com/xphoniex)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- `internal/fs`: Use `/` as a fallback if no mountpoints are specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2705`](https://github.com/polybar/polybar/pull/2705))
|
- `internal/fs`: Use `/` as a fallback if no mountpoints are specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2705`](https://github.com/polybar/polybar/pull/2705))
|
||||||
|
@ -20,3 +20,5 @@ set(SETTING_PATH_MESSAGING_FIFO "/tmp/polybar_mqueue.%pid%"
|
|||||||
CACHE STRING "Path to file containing the current temperature")
|
CACHE STRING "Path to file containing the current temperature")
|
||||||
set(SETTING_PATH_TEMPERATURE_INFO "/sys/class/thermal/thermal_zone%zone%/temp"
|
set(SETTING_PATH_TEMPERATURE_INFO "/sys/class/thermal/thermal_zone%zone%/temp"
|
||||||
CACHE STRING "Path to file containing the current temperature")
|
CACHE STRING "Path to file containing the current temperature")
|
||||||
|
set(SETTING_PATH_THERMAL_ZONE_WILDCARD "/sys/class/thermal/thermal_zone*"
|
||||||
|
CACHE STRING "Wildcard path to different thermal zones")
|
||||||
|
@ -30,6 +30,7 @@ namespace modules {
|
|||||||
ramp_t m_ramp;
|
ramp_t m_ramp;
|
||||||
|
|
||||||
string m_path;
|
string m_path;
|
||||||
|
string m_zone_type;
|
||||||
int m_zone = 0;
|
int m_zone = 0;
|
||||||
// Base temperature used for where to start the ramp
|
// Base temperature used for where to start the ramp
|
||||||
int m_tempbase = 0;
|
int m_tempbase = 0;
|
||||||
|
@ -66,6 +66,7 @@ extern const char* const PATH_CPU_INFO;
|
|||||||
extern const char* const PATH_MEMORY_INFO;
|
extern const char* const PATH_MEMORY_INFO;
|
||||||
extern const char* const PATH_MESSAGING_FIFO;
|
extern const char* const PATH_MESSAGING_FIFO;
|
||||||
extern const char* const PATH_TEMPERATURE_INFO;
|
extern const char* const PATH_TEMPERATURE_INFO;
|
||||||
|
extern const char* const PATH_THERMAL_ZONE_WILDCARD;
|
||||||
extern const char* const WIRELESS_LIB;
|
extern const char* const WIRELESS_LIB;
|
||||||
|
|
||||||
bool version_details(const std::vector<std::string>& args);
|
bool version_details(const std::vector<std::string>& args);
|
||||||
|
@ -16,12 +16,33 @@ namespace modules {
|
|||||||
temperature_module::temperature_module(const bar_settings& bar, string name_)
|
temperature_module::temperature_module(const bar_settings& bar, string name_)
|
||||||
: timer_module<temperature_module>(bar, move(name_)) {
|
: timer_module<temperature_module>(bar, move(name_)) {
|
||||||
m_zone = m_conf.get(name(), "thermal-zone", 0);
|
m_zone = m_conf.get(name(), "thermal-zone", 0);
|
||||||
|
m_zone_type = m_conf.get(name(), "zone-type", ""s);
|
||||||
m_path = m_conf.get(name(), "hwmon-path", ""s);
|
m_path = m_conf.get(name(), "hwmon-path", ""s);
|
||||||
m_tempbase = m_conf.get(name(), "base-temperature", 0);
|
m_tempbase = m_conf.get(name(), "base-temperature", 0);
|
||||||
m_tempwarn = m_conf.get(name(), "warn-temperature", 80);
|
m_tempwarn = m_conf.get(name(), "warn-temperature", 80);
|
||||||
set_interval(1s);
|
set_interval(1s);
|
||||||
m_units = m_conf.get(name(), "units", m_units);
|
m_units = m_conf.get(name(), "units", m_units);
|
||||||
|
|
||||||
|
if (!m_zone_type.empty()) {
|
||||||
|
bool zone_found = false;
|
||||||
|
vector<string> zone_paths = file_util::glob(PATH_THERMAL_ZONE_WILDCARD);
|
||||||
|
vector<string> available_zones;
|
||||||
|
for (auto &z: zone_paths) {
|
||||||
|
string zone_file = z + "/type";
|
||||||
|
string z_zone_type = string_util::strip_trailing_newline(file_util::contents(zone_file));
|
||||||
|
available_zones.push_back(z_zone_type);
|
||||||
|
if (z_zone_type == m_zone_type) {
|
||||||
|
m_path = z + "/temp";
|
||||||
|
zone_found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!zone_found) {
|
||||||
|
throw module_error("zone-type '" + m_zone_type + "' was not found, available zone types: " + string_util::join(available_zones, ", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_path.empty()) {
|
if (m_path.empty()) {
|
||||||
m_path = string_util::replace(PATH_TEMPERATURE_INFO, "%zone%", to_string(m_zone));
|
m_path = string_util::replace(PATH_TEMPERATURE_INFO, "%zone%", to_string(m_zone));
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ const char* const PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
|
|||||||
const char* const PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
const char* const PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
||||||
const char* const PATH_MESSAGING_FIFO{"@SETTING_PATH_MESSAGING_FIFO@"};
|
const char* const PATH_MESSAGING_FIFO{"@SETTING_PATH_MESSAGING_FIFO@"};
|
||||||
const char* const PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_INFO@"};
|
const char* const PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_INFO@"};
|
||||||
|
const char* const PATH_THERMAL_ZONE_WILDCARD{"@SETTING_PATH_THERMAL_ZONE_WILDCARD@"};
|
||||||
const char* const WIRELESS_LIB{"@WIRELESS_LIB@"};
|
const char* const WIRELESS_LIB{"@WIRELESS_LIB@"};
|
||||||
|
|
||||||
bool version_details(const std::vector<std::string>& args) {
|
bool version_details(const std::vector<std::string>& args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user