blob: cb94f0d7c3618df539088750738cea24815182f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
use crate::config::CONFIG;
use crate::types::ThreadsData;
use std::fs::read_to_string;
// getting cpu temperature
pub async fn get_cpu_temp() -> ThreadsData {
let buf = match read_to_string(&CONFIG.cpu_temperature.path) {
Ok(data) => data,
_ => return ThreadsData::CpuTemp(String::from("Error reading temp")),
};
let value = buf.trim().parse::<f32>().unwrap();
let result = format!(
" {} {}° {}",
CONFIG.cpu_temperature.icon,
value / 1000.0,
CONFIG.seperator
);
ThreadsData::CpuTemp(result)
}
|