File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,22 @@ static CPU_TEMPERATURE_PATH: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
47
47
cpu_temperature_path. map ( |( _, path) | path)
48
48
} ) ;
49
49
50
+ fn search_for_first_temp < S : AsRef < str > > ( base_path : S ) -> Option < PathBuf > {
51
+ glob ( & format ! ( "{}/temp*_input" , base_path. as_ref( ) ) )
52
+ . unwrap ( )
53
+ . flatten ( )
54
+ . next ( )
55
+ }
56
+
50
57
/// Looks for hwmons with the given names.
51
58
/// This function is a bit inefficient since the `names` array is considered to be ordered by priority.
52
59
fn search_for_hwmons ( names : & [ & ' static str ] ) -> Option < ( & ' static str , PathBuf ) > {
53
60
for temp_name in names {
54
61
for path in ( glob ( "/sys/class/hwmon/hwmon*" ) . unwrap ( ) ) . flatten ( ) {
55
62
if let Ok ( read_name) = std:: fs:: read_to_string ( path. join ( "name" ) ) {
56
63
if & read_name. trim_end ( ) == temp_name {
57
- return Some ( ( temp_name, path. join ( "temp1_input" ) ) ) ;
64
+ return search_for_first_temp ( path. to_string_lossy ( ) )
65
+ . map ( |first_temp| ( * temp_name, first_temp) ) ;
58
66
}
59
67
}
60
68
}
You can’t perform that action at this time.
0 commit comments