This commit is contained in:
2026-03-13 15:32:43 +01:00
commit 311f517f67
17 changed files with 1833 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
use crate::config::Config;
use crate::modules::WaybarModule;
use crate::output::WaybarOutput;
use crate::state::SharedState;
use anyhow::Result;
pub struct CpuModule;
impl WaybarModule for CpuModule {
fn run(&self, _config: &Config, state: &SharedState, _args: &[&str]) -> Result<WaybarOutput> {
let (usage, temp, model) = {
if let Ok(state_lock) = state.read() {
(
state_lock.cpu.usage,
state_lock.cpu.temp,
state_lock.cpu.model.clone(),
)
} else {
(0.0, 0.0, String::from("Unknown"))
}
};
let text = format!("{:.1}% {:.1}C", usage, temp);
let class = if usage > 95.0 {
"max"
} else if usage > 75.0 {
"high"
} else {
"normal"
};
Ok(WaybarOutput {
text: format!("CPU: {}", text),
tooltip: Some(model),
class: Some(class.to_string()),
percentage: Some(usage as u8),
})
}
}