about summary refs log tree commit diff stats
path: root/pkgs/by-name/ya/yambar-modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ya/yambar-modules/.envrc (renamed from pkgs/by-name/ya/yambar-cpu/.envrc)0
-rw-r--r--pkgs/by-name/ya/yambar-modules/.gitignore (renamed from pkgs/by-name/ya/yambar-cpu/.gitignore)0
-rw-r--r--pkgs/by-name/ya/yambar-modules/Cargo.lock (renamed from pkgs/by-name/ya/yambar-cpu/Cargo.lock)18
-rw-r--r--pkgs/by-name/ya/yambar-modules/Cargo.toml (renamed from pkgs/by-name/ya/yambar-cpu/Cargo.toml)2
-rw-r--r--pkgs/by-name/ya/yambar-modules/flake.lock (renamed from pkgs/by-name/ya/yambar-memory/flake.lock)6
-rw-r--r--pkgs/by-name/ya/yambar-modules/flake.nix (renamed from pkgs/by-name/ya/yambar-cpu/flake.nix)2
-rw-r--r--pkgs/by-name/ya/yambar-modules/package.nix (renamed from pkgs/by-name/ya/yambar-cpu/package.nix)4
-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.rs26
-rw-r--r--pkgs/by-name/ya/yambar-modules/src/memory.rs (renamed from pkgs/by-name/ya/yambar-memory/src/main.rs)3
10 files changed, 44 insertions, 20 deletions
diff --git a/pkgs/by-name/ya/yambar-cpu/.envrc b/pkgs/by-name/ya/yambar-modules/.envrc
index 2f9f1a81..2f9f1a81 100644
--- a/pkgs/by-name/ya/yambar-cpu/.envrc
+++ b/pkgs/by-name/ya/yambar-modules/.envrc
diff --git a/pkgs/by-name/ya/yambar-cpu/.gitignore b/pkgs/by-name/ya/yambar-modules/.gitignore
index ea8c4bf7..ea8c4bf7 100644
--- a/pkgs/by-name/ya/yambar-cpu/.gitignore
+++ b/pkgs/by-name/ya/yambar-modules/.gitignore
diff --git a/pkgs/by-name/ya/yambar-cpu/Cargo.lock b/pkgs/by-name/ya/yambar-modules/Cargo.lock
index 43d40482..6b689d29 100644
--- a/pkgs/by-name/ya/yambar-cpu/Cargo.lock
+++ b/pkgs/by-name/ya/yambar-modules/Cargo.lock
@@ -15,13 +15,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
 
 [[package]]
-name = "cpu_usage"
-version = "0.1.0"
-dependencies = [
- "sysinfo",
-]
-
-[[package]]
 name = "crossbeam-deque"
 version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -54,9 +47,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
 
 [[package]]
 name = "libc"
-version = "0.2.164"
+version = "0.2.167"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
+checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
 
 [[package]]
 name = "ntapi"
@@ -129,3 +122,10 @@ name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "yambar-modules"
+version = "0.1.0"
+dependencies = [
+ "sysinfo",
+]
diff --git a/pkgs/by-name/ya/yambar-cpu/Cargo.toml b/pkgs/by-name/ya/yambar-modules/Cargo.toml
index 6d66301a..8e3995fe 100644
--- a/pkgs/by-name/ya/yambar-cpu/Cargo.toml
+++ b/pkgs/by-name/ya/yambar-modules/Cargo.toml
@@ -1,5 +1,5 @@
 [package]
-name = "cpu_usage"
+name = "yambar-modules"
 version = "0.1.0"
 edition = "2021"
 
diff --git a/pkgs/by-name/ya/yambar-memory/flake.lock b/pkgs/by-name/ya/yambar-modules/flake.lock
index aaddd6a5..8043448e 100644
--- a/pkgs/by-name/ya/yambar-memory/flake.lock
+++ b/pkgs/by-name/ya/yambar-modules/flake.lock
@@ -20,11 +20,11 @@
     },
     "nixpkgs": {
       "locked": {
-        "lastModified": 1731890469,
-        "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=",
+        "lastModified": 1732617236,
+        "narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "5083ec887760adfe12af64830a66807423a859a7",
+        "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e",
         "type": "github"
       },
       "original": {
diff --git a/pkgs/by-name/ya/yambar-cpu/flake.nix b/pkgs/by-name/ya/yambar-modules/flake.nix
index 3a27bccf..e3d0cd49 100644
--- a/pkgs/by-name/ya/yambar-cpu/flake.nix
+++ b/pkgs/by-name/ya/yambar-modules/flake.nix
@@ -1,5 +1,5 @@
 {
-  description = "A smart way to check your cpu usage";
+  description = "Extension modules for yambar(1)";
 
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
diff --git a/pkgs/by-name/ya/yambar-cpu/package.nix b/pkgs/by-name/ya/yambar-modules/package.nix
index 90f1a558..79281429 100644
--- a/pkgs/by-name/ya/yambar-cpu/package.nix
+++ b/pkgs/by-name/ya/yambar-modules/package.nix
@@ -1,6 +1,6 @@
 {rustPlatform}:
 rustPlatform.buildRustPackage {
-  pname = "yambar-cpu";
+  pname = "yambar-modules";
   version = "0.1.0";
 
   src = ./.;
@@ -9,6 +9,6 @@ rustPlatform.buildRustPackage {
   };
 
   meta = {
-    mainProgram = "cpu_usage";
+    mainProgram = "yambar-modules";
   };
 }
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();