diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/ya/yambar-modules/src/cpu.rs (renamed from pkgs/by-name/ya/yambar-cpu/src/main.rs) | 3 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-modules/src/main.rs | 26 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-modules/src/memory.rs (renamed from pkgs/by-name/ya/yambar-memory/src/main.rs) | 3 |
3 files changed, 28 insertions, 4 deletions
diff --git a/pkgs/by-name/ya/yambar-cpu/src/main.rs b/pkgs/by-name/ya/yambar-modules/src/cpu.rs index 9314b81e..5a6dd084 100644 --- a/pkgs/by-name/ya/yambar-cpu/src/main.rs +++ b/pkgs/by-name/ya/yambar-modules/src/cpu.rs @@ -2,10 +2,9 @@ use std::{thread, time::Duration}; use sysinfo::{CpuExt, System, SystemExt}; -fn main() { +pub fn cpu() { let mut sys = System::new(); - // Number of CPUs: loop { sys.refresh_cpu(); let cpu_usage: f32 = sys.cpus().iter().map(|cpu| cpu.cpu_usage()).sum(); diff --git a/pkgs/by-name/ya/yambar-modules/src/main.rs b/pkgs/by-name/ya/yambar-modules/src/main.rs new file mode 100644 index 00000000..315c3be7 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/src/main.rs @@ -0,0 +1,26 @@ +use std::{env::args, process}; + +mod cpu; +mod memory; + +fn main() { + let args: Vec<String> = args().collect(); + + if args.len() != 2 { + eprintln!("Usage: yambar-modules cpu|memory"); + process::exit(1); + } + + match args[1].as_str() { + "cpu" => { + cpu::cpu(); + } + "memory" => { + memory::memory(); + } + other => { + eprintln!("'{other}' is not a valid command. Only 'cpu' or 'memory'."); + process::exit(1); + } + } +} diff --git a/pkgs/by-name/ya/yambar-memory/src/main.rs b/pkgs/by-name/ya/yambar-modules/src/memory.rs index ea9e6f39..6da714cc 100644 --- a/pkgs/by-name/ya/yambar-memory/src/main.rs +++ b/pkgs/by-name/ya/yambar-modules/src/memory.rs @@ -2,10 +2,9 @@ use std::{thread, time::Duration}; use sysinfo::{System, SystemExt}; -fn main() { +pub fn memory() { let mut sys = System::new(); - // Number of CPUs: loop { sys.refresh_memory(); |