updated with custom configuration

This commit is contained in:
2026-03-13 17:07:05 +01:00
parent e19fb69c72
commit 4cf61b6197
11 changed files with 363 additions and 127 deletions
+7 -3
View File
@@ -7,7 +7,7 @@ use anyhow::Result;
pub struct CpuModule;
impl WaybarModule for CpuModule {
fn run(&self, _config: &Config, state: &SharedState, _args: &[&str]) -> Result<WaybarOutput> {
fn run(&self, config: &Config, state: &SharedState, _args: &[&str]) -> Result<WaybarOutput> {
let (usage, temp, model) = {
if let Ok(state_lock) = state.read() {
(
@@ -20,7 +20,11 @@ impl WaybarModule for CpuModule {
}
};
let text = format!("{:.1}% {:.1}C", usage, temp);
let text = config.cpu.format
.replace("{usage:>4.1}", &format!("{:>4.1}", usage))
.replace("{temp:>4.1}", &format!("{:>4.1}", temp))
.replace("{usage}", &format!("{:.1}", usage))
.replace("{temp}", &format!("{:.1}", temp));
let class = if usage > 95.0 {
"max"
@@ -31,7 +35,7 @@ impl WaybarModule for CpuModule {
};
Ok(WaybarOutput {
text: format!("CPU: {}", text),
text,
tooltip: Some(model),
class: Some(class.to_string()),
percentage: Some(usage as u8),