mirror of
https://github.com/danog/ytop.git
synced 2024-11-29 20:19:01 +01:00
Fixes missing temperature on mac os
This commit is contained in:
parent
bce6b2e193
commit
6b94b79f84
495
Cargo.lock
generated
495
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -26,3 +26,6 @@ size = "0.1.2"
|
||||
structopt = "0.3.13"
|
||||
# tui = { version = "0.8.0", features = ["crossterm"] }
|
||||
tui = { git = "https://github.com/cjbassi/tui-rs", branch = "master", default-features = false, features = ["crossterm"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
sysinfo = "0.14.1"
|
||||
|
@ -7,6 +7,9 @@ use crate::colorscheme::Colorscheme;
|
||||
use crate::update::UpdatableWidget;
|
||||
use crate::widgets::block;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use sysinfo::{ComponentExt, System, SystemExt};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use psutil::sensors;
|
||||
|
||||
@ -59,7 +62,21 @@ impl UpdatableWidget for TempWidget<'_> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn update(&mut self) {}
|
||||
fn update(&mut self) {
|
||||
self.temp_data = Vec::new();
|
||||
|
||||
let sys = System::new_all();
|
||||
let sensor_data = sys.get_components();
|
||||
|
||||
for component in sensor_data {
|
||||
let num: f64 = component.get_temperature() as f64;
|
||||
self.temp_data
|
||||
.push((component.get_label().to_string(), num));
|
||||
}
|
||||
|
||||
self.temp_data
|
||||
.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
|
||||
}
|
||||
|
||||
fn get_update_interval(&self) -> Ratio<u64> {
|
||||
self.update_interval
|
||||
|
Loading…
Reference in New Issue
Block a user