
* Add async deps * Rename blocks to 'BlockManager' * Refactor "Blocks" to own module * Make all util fn async * Remove stray println
17 lines
436 B
Rust
17 lines
436 B
Rust
use crate::config::CONFIG;
|
|
use crate::types::ThreadsData;
|
|
|
|
use nix::libc::{c_double, c_int, getloadavg};
|
|
|
|
pub async fn get_load_avg() -> ThreadsData {
|
|
let mut data: [c_double; 3] = [0f64; 3];
|
|
unsafe { getloadavg(data.as_mut_ptr(), data.len() as c_int) };
|
|
let [load, _, _] = data;
|
|
let data = format!(
|
|
" {} {:.2} {}",
|
|
CONFIG.loadavg.icon, load, CONFIG.seperator
|
|
);
|
|
|
|
ThreadsData::LoadAvg(data)
|
|
}
|