Fix no temperature on Raspberry Pi
@@ -180,9 +180,8 @@ impl ComponentExt for Component {
}
pub fn get_components() -> Vec<Component> {
- if let Ok(dir) = read_dir(&Path::new("/sys/class/hwmon/")) {
let mut components = Vec::with_capacity(10);
-
+ if let Ok(dir) = read_dir(&Path::new("/sys/class/hwmon/")) {
for entry in dir {
if let Ok(entry) = entry {
let entry = entry.path();
@@ -200,15 +199,18 @@ pub fn get_components() -> Vec<Component> {
}
}
components.sort_by(|c1, c2| c1.label.to_lowercase().cmp(&c2.label.to_lowercase()));
- components
- } else if is_file("/sys/class/thermal/thermal_zone0/temp") {
+ }
+ if is_file("/sys/class/thermal/thermal_zone0/temp") {
// Specfic to raspberry pi.
- vec![Component::new(
+ components.push(Component::new(
"CPU".to_owned(),
Path::new("/sys/class/thermal/thermal_zone0/temp"),
None,
None,
- )]
+ ));
+ }
+ if components.len() != 0 {
+ components
} else {
Vec::new()
}
