Skip to content

Commit

Permalink
Merge pull request #328 from arctic-alpaca/temperature-fix
Browse files Browse the repository at this point in the history
Fix no temperature on Raspberry Pi
  • Loading branch information
GuillaumeGomez authored Jun 24, 2020
2 parents 445293a + 8d247b0 commit 81a825e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/linux/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ impl ComponentExt for Component {
}

pub fn get_components() -> Vec<Component> {
let mut components = Vec::with_capacity(10);
if let Ok(dir) = read_dir(&Path::new("/sys/class/hwmon/")) {
let mut components = Vec::with_capacity(10);

for entry in dir {
if let Ok(entry) = entry {
let entry = entry.path();
Expand All @@ -200,16 +199,15 @@ 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,
)]
} else {
Vec::new()
));
}
components
}

0 comments on commit 81a825e

Please sign in to comment.