Skip to content

Commit

Permalink
add back an empty name and value
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Dec 20, 2023
1 parent 72ef30e commit a605735
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug Fixes

- [#1314](https://github.com/ClementTsang/bottom/pull/1314): Fix fat32 mounts not showing up in macOS.
- [#1355](https://github.com/ClementTsang/bottom/pull/1355): Reduce chances of devices waking up due to temperature checks on Linux.

## [0.9.6] - 2023-08-26

Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester/nvidia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn get_nvidia_vecs(

temp_vec.push(TempHarvest {
name: name.clone(),
temperature,
temperature: Some(temperature),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester/temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::app::Filter;
#[derive(Default, Debug, Clone)]
pub struct TempHarvest {
pub name: String,
pub temperature: f32,
pub temperature: Option<f32>,
}

#[derive(Clone, Debug, Copy, PartialEq, Eq, Default)]
Expand Down
14 changes: 10 additions & 4 deletions src/app/data_harvester/temperature/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ fn finalize_name(
None => label,
},
(Some(name), None) => name,
(None, None) => match &fallback_sensor_name {
Some(sensor_name) => sensor_name.clone(),
(None, None) => match fallback_sensor_name {
Some(sensor_name) => sensor_name.to_owned(),
None => EMPTY_NAME.to_string(),
},
};
Expand Down Expand Up @@ -204,6 +204,12 @@ fn hwmon_temperatures(temp_type: &TemperatureType, filter: &Option<Filter>) -> H
let sensor_name = read_to_string_lossy(file_path.join("name"));

if !is_device_awake(&file_path) {
if let Some(sensor_name) = sensor_name {
temperatures.push(TempHarvest {
name: sensor_name,
temperature: None,
});
}
continue;
}

Expand Down Expand Up @@ -285,7 +291,7 @@ fn hwmon_temperatures(temp_type: &TemperatureType, filter: &Option<Filter>) -> H

temperatures.push(TempHarvest {
name,
temperature: temp_type.convert_temp_unit(temp_celsius),
temperature: Some(temp_type.convert_temp_unit(temp_celsius)),
});
}
}
Expand Down Expand Up @@ -330,7 +336,7 @@ fn add_thermal_zone_temperatures(

temperatures.push(TempHarvest {
name,
temperature: temp_type.convert_temp_unit(temp_celsius),
temperature: Some(temp_type.convert_temp_unit(temp_celsius)),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/data_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl ConvertedData {
data.temp_harvest.iter().for_each(|temp_harvest| {
self.temp_data.push(TempWidgetData {
sensor: KString::from_ref(&temp_harvest.name),
temperature_value: temp_harvest.temperature.ceil() as u64,
temperature_value: temp_harvest.temperature.map(|temp| temp.ceil() as u64),
temperature_type,
});
});
Expand Down
20 changes: 12 additions & 8 deletions src/widgets/temperature_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
#[derive(Clone, Debug)]
pub struct TempWidgetData {
pub sensor: KString,
pub temperature_value: u64,
pub temperature_value: Option<u64>,
pub temperature_type: TemperatureType,
}

Expand All @@ -37,13 +37,17 @@ impl ColumnHeader for TempWidgetColumn {

impl TempWidgetData {
pub fn temperature(&self) -> KString {
let temp_val = self.temperature_value.to_string();
let temp_type = match self.temperature_type {
TemperatureType::Celsius => "°C",
TemperatureType::Kelvin => "K",
TemperatureType::Fahrenheit => "°F",
};
concat_string!(temp_val, temp_type).into()
match self.temperature_value {
Some(temp_val) => {
let temp_type = match self.temperature_type {
TemperatureType::Celsius => "°C",
TemperatureType::Kelvin => "K",
TemperatureType::Fahrenheit => "°F",
};
concat_string!(temp_val.to_string(), temp_type).into()
}
None => "N/A".to_string().into(),
}
}
}

Expand Down

0 comments on commit a605735

Please sign in to comment.