mirror of
https://github.com/ClementTsang/bottom.git
synced 2024-11-03 21:04:38 +03:00
bug: Use correct labels for sensors in Linux (#215)
Update temperature sensors in Linux to use labels + names rather than just names.
This commit is contained in:
parent
5aa7b4df08
commit
5ed573157c
@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- [#211](https://github.com/ClementTsang/bottom/pull/211): Fixes a bug where you could move down in the process widget even if the process widget search was closed.
|
||||
|
||||
- [#215](https://github.com/ClementTsang/bottom/pull/215): Add labels to Linux temperature values.
|
||||
|
||||
## [0.4.7] - 2020-08-26
|
||||
|
||||
### Bug Fixes
|
||||
|
@ -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) {
|
||||
|
@ -93,7 +93,12 @@ pub fn convert_temp_row(app: &App) -> Vec<Vec<String>> {
|
||||
} else {
|
||||
for sensor in ¤t_data.temp_harvest {
|
||||
sensor_vector.push(vec![
|
||||
sensor.component_name.to_string(),
|
||||
match (&sensor.component_name, &sensor.component_label) {
|
||||
(Some(name), Some(label)) => format!("{}: {}", name, label),
|
||||
(None, Some(label)) => label.to_string(),
|
||||
(Some(name), None) => name.to_string(),
|
||||
(None, None) => String::default(),
|
||||
},
|
||||
(sensor.temperature.ceil() as u64).to_string()
|
||||
+ match temp_type {
|
||||
data_harvester::temperature::TemperatureType::Celsius => "C",
|
||||
|
Loading…
Reference in New Issue
Block a user