From 8234145bf250f7bfb4dd06ef1c9f5543c4bace8e Mon Sep 17 00:00:00 2001 From: druskus20 Date: Sat, 21 Aug 2021 18:30:06 +0200 Subject: [PATCH] Renamed system stat functions --- crates/eww/src/config/inbuilt.rs | 8 ++++---- crates/eww/src/config/system_stats.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/eww/src/config/inbuilt.rs b/crates/eww/src/config/inbuilt.rs index c2c4b50..343ac1f 100644 --- a/crates/eww/src/config/inbuilt.rs +++ b/crates/eww/src/config/inbuilt.rs @@ -23,13 +23,13 @@ macro_rules! builtin_vars { pub fn get_inbuilt_vars() -> HashMap { builtin_vars! {Duration::new(2, 0), // @desc EWW_TEMPS - Heat of the components in Celcius\nExample: `{(CPU_TEMPS.core_1 + CPU_TEMPS.core_2) / 2}` - "EWW_TEMPS" => || Ok(DynVal::from(cores())), + "EWW_TEMPS" => || Ok(DynVal::from(get_core_temperatures())), // @desc EWW_RAM - The current RAM + Swap usage - "EWW_RAM" => || Ok(DynVal::from(format!("{:.2}", ram()))), + "EWW_RAM" => || Ok(DynVal::from(format!("{:.2}", get_ram()))), // @desc EWW_DISK - Information on on all mounted partitions (Might report inaccurately on some filesystems, like btrfs)\nExample: `{EWW_DISK["/"]}` - "EWW_DISK" => || Ok(DynVal::from(disk())), + "EWW_DISK" => || Ok(DynVal::from(get_disks())), // @desc EWW_BATTERY - Battery capacity in procent of the main battery "EWW_BATTERY" => || Ok(DynVal::from( @@ -43,7 +43,7 @@ pub fn get_inbuilt_vars() -> HashMap { )), // @desc EWW_CPU_USAGE - Average CPU usage (all cores) since the last update (No MacOS support) - "EWW_CPU_USAGE" => || Ok(DynVal::from(get_avg_cpu_usage())), + "EWW_CPU_USAGE" => || Ok(DynVal::from(get_cpus())), // @desc EWW_NET - Bytes up/down on all interfaces "EWW_NET" => || Ok(DynVal::from(net())), diff --git a/crates/eww/src/config/system_stats.rs b/crates/eww/src/config/system_stats.rs index 1ddb4e4..a0d7b63 100644 --- a/crates/eww/src/config/system_stats.rs +++ b/crates/eww/src/config/system_stats.rs @@ -7,7 +7,7 @@ use sysinfo::{ComponentExt, DiskExt, NetworkExt, NetworksExt, ProcessorExt, Syst static SYSTEM: Lazy> = Lazy::new(|| Mutex::new(System::new())); -pub fn disk() -> String { +pub fn get_disks() -> String { let mut c = SYSTEM.lock().unwrap(); c.refresh_disks_list(); @@ -26,13 +26,13 @@ pub fn disk() -> String { ) } -pub fn ram() -> f32 { +pub fn get_ram() -> f32 { let mut c = SYSTEM.lock().unwrap(); c.refresh_memory(); (c.get_used_memory() as f32 + c.get_used_swap() as f32) / 1_000_000f32 } -pub fn cores() -> String { +pub fn get_core_temperatures() -> String { let mut c = SYSTEM.lock().unwrap(); c.refresh_components_list(); c.refresh_components(); @@ -45,7 +45,7 @@ pub fn cores() -> String { ) } -pub fn get_avg_cpu_usage() -> String { +pub fn get_cpus() -> String { let mut c = SYSTEM.lock().unwrap(); c.refresh_cpu(); let processors = c.get_processors(); @@ -133,7 +133,7 @@ pub fn get_battery_capacity() -> Result { #[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "linux"))] pub fn get_battery_capacity() -> Result { - anyhow!("eww doesn't support your OS for getting the battery capacity") + anyhow!("Eww doesn't support your OS for getting the battery capacity") } pub fn net() -> String {