diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-08-31 20:02:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 20:02:48 -0400 |
commit | 5ed573157c00a0617c786edde0a241bd75e81666 (patch) | |
tree | 93d3ba0e6d5e5ed8761749ef3cd902befcc7436d /src/app | |
parent | 5aa7b4df082bce4d029757c911893a93347d0d61 (diff) |
bug: Use correct labels for sensors in Linux (#215)
Update temperature sensors in Linux to use labels + names rather than just names.
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/data_harvester/temperature.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/app/data_harvester/temperature.rs b/src/app/data_harvester/temperature.rs index b0a39e3d..337ed7b2 100644 --- a/src/app/data_harvester/temperature.rs +++ b/src/app/data_harvester/temperature.rs @@ -6,7 +6,8 @@ use sysinfo::{ComponentExt, System, SystemExt}; #[derive(Default, Debug, Clone)] pub struct TempHarvest { - pub component_name: String, + pub component_name: Option<String>, + pub component_label: Option<String>, pub temperature: f32, } @@ -37,7 +38,12 @@ pub async fn get_temperature_data( while let Some(sensor) = sensor_data.next().await { if let Ok(sensor) = sensor { temperature_vec.push(TempHarvest { - component_name: sensor.unit().to_string(), + component_name: Some(sensor.unit().to_string()), + component_label: if let Some(label) = sensor.label() { + Some(label.to_string()) + } else { + None + }, temperature: match temp_type { TemperatureType::Celsius => sensor .current() @@ -58,7 +64,8 @@ pub async fn get_temperature_data( let sensor_data = sys.get_components(); for component in sensor_data { temperature_vec.push(TempHarvest { - component_name: component.get_label().to_string(), + component_name: None, + component_label: Some(component.get_label().to_string()), temperature: match temp_type { TemperatureType::Celsius => component.get_temperature(), TemperatureType::Kelvin => { @@ -73,6 +80,7 @@ pub async fn get_temperature_data( } // By default, sort temperature, then by alphabetically! + // TODO: [TEMPS] Allow users to control this. // Note we sort in reverse here; we want greater temps to be higher priority. temperature_vec.sort_by(|a, b| match a.temperature.partial_cmp(&b.temperature) { |