updated with custom configuration
This commit is contained in:
+7
-3
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user