From cbd9aec4bf2e488156f5dc101271d572af0cd2ca Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 29 Nov 2024 18:48:07 +0100 Subject: chore(pkgs/by-name/ya/{cpu,memory}): Merge There is no reason to keep these two programs separate. --- pkgs/by-name/ya/yambar-cpu/.envrc | 2 - pkgs/by-name/ya/yambar-cpu/.gitignore | 1 - pkgs/by-name/ya/yambar-cpu/Cargo.lock | 131 --------------------------- pkgs/by-name/ya/yambar-cpu/Cargo.toml | 9 -- pkgs/by-name/ya/yambar-cpu/flake.lock | 61 ------------- pkgs/by-name/ya/yambar-cpu/flake.nix | 32 ------- pkgs/by-name/ya/yambar-cpu/package.nix | 14 --- pkgs/by-name/ya/yambar-cpu/src/main.rs | 22 ----- pkgs/by-name/ya/yambar-cpu/update.sh | 6 -- pkgs/by-name/ya/yambar-memory/.envrc | 2 - pkgs/by-name/ya/yambar-memory/.gitignore | 1 - pkgs/by-name/ya/yambar-memory/Cargo.lock | 131 --------------------------- pkgs/by-name/ya/yambar-memory/Cargo.toml | 9 -- pkgs/by-name/ya/yambar-memory/flake.lock | 61 ------------- pkgs/by-name/ya/yambar-memory/flake.nix | 32 ------- pkgs/by-name/ya/yambar-memory/package.nix | 14 --- pkgs/by-name/ya/yambar-memory/src/main.rs | 30 ------ pkgs/by-name/ya/yambar-memory/update.sh | 6 -- pkgs/by-name/ya/yambar-modules/.envrc | 2 + pkgs/by-name/ya/yambar-modules/.gitignore | 1 + pkgs/by-name/ya/yambar-modules/Cargo.lock | 131 +++++++++++++++++++++++++++ pkgs/by-name/ya/yambar-modules/Cargo.toml | 9 ++ pkgs/by-name/ya/yambar-modules/flake.lock | 61 +++++++++++++ pkgs/by-name/ya/yambar-modules/flake.nix | 32 +++++++ pkgs/by-name/ya/yambar-modules/package.nix | 14 +++ pkgs/by-name/ya/yambar-modules/src/cpu.rs | 21 +++++ pkgs/by-name/ya/yambar-modules/src/main.rs | 26 ++++++ pkgs/by-name/ya/yambar-modules/src/memory.rs | 29 ++++++ 28 files changed, 326 insertions(+), 564 deletions(-) delete mode 100644 pkgs/by-name/ya/yambar-cpu/.envrc delete mode 100644 pkgs/by-name/ya/yambar-cpu/.gitignore delete mode 100644 pkgs/by-name/ya/yambar-cpu/Cargo.lock delete mode 100644 pkgs/by-name/ya/yambar-cpu/Cargo.toml delete mode 100644 pkgs/by-name/ya/yambar-cpu/flake.lock delete mode 100644 pkgs/by-name/ya/yambar-cpu/flake.nix delete mode 100644 pkgs/by-name/ya/yambar-cpu/package.nix delete mode 100644 pkgs/by-name/ya/yambar-cpu/src/main.rs delete mode 100755 pkgs/by-name/ya/yambar-cpu/update.sh delete mode 100644 pkgs/by-name/ya/yambar-memory/.envrc delete mode 100644 pkgs/by-name/ya/yambar-memory/.gitignore delete mode 100644 pkgs/by-name/ya/yambar-memory/Cargo.lock delete mode 100644 pkgs/by-name/ya/yambar-memory/Cargo.toml delete mode 100644 pkgs/by-name/ya/yambar-memory/flake.lock delete mode 100644 pkgs/by-name/ya/yambar-memory/flake.nix delete mode 100644 pkgs/by-name/ya/yambar-memory/package.nix delete mode 100644 pkgs/by-name/ya/yambar-memory/src/main.rs delete mode 100755 pkgs/by-name/ya/yambar-memory/update.sh create mode 100644 pkgs/by-name/ya/yambar-modules/.envrc create mode 100644 pkgs/by-name/ya/yambar-modules/.gitignore create mode 100644 pkgs/by-name/ya/yambar-modules/Cargo.lock create mode 100644 pkgs/by-name/ya/yambar-modules/Cargo.toml create mode 100644 pkgs/by-name/ya/yambar-modules/flake.lock create mode 100644 pkgs/by-name/ya/yambar-modules/flake.nix create mode 100644 pkgs/by-name/ya/yambar-modules/package.nix create mode 100644 pkgs/by-name/ya/yambar-modules/src/cpu.rs create mode 100644 pkgs/by-name/ya/yambar-modules/src/main.rs create mode 100644 pkgs/by-name/ya/yambar-modules/src/memory.rs (limited to 'pkgs/by-name') diff --git a/pkgs/by-name/ya/yambar-cpu/.envrc b/pkgs/by-name/ya/yambar-cpu/.envrc deleted file mode 100644 index 2f9f1a81..00000000 --- a/pkgs/by-name/ya/yambar-cpu/.envrc +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -use flake diff --git a/pkgs/by-name/ya/yambar-cpu/.gitignore b/pkgs/by-name/ya/yambar-cpu/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/pkgs/by-name/ya/yambar-cpu/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/pkgs/by-name/ya/yambar-cpu/Cargo.lock b/pkgs/by-name/ya/yambar-cpu/Cargo.lock deleted file mode 100644 index 43d40482..00000000 --- a/pkgs/by-name/ya/yambar-cpu/Cargo.lock +++ /dev/null @@ -1,131 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -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" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "libc" -version = "0.2.164" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" - -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi", -] - -[[package]] -name = "once_cell" -version = "1.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "sysinfo" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b" -dependencies = [ - "cfg-if", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/pkgs/by-name/ya/yambar-cpu/Cargo.toml b/pkgs/by-name/ya/yambar-cpu/Cargo.toml deleted file mode 100644 index 6d66301a..00000000 --- a/pkgs/by-name/ya/yambar-cpu/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "cpu_usage" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -sysinfo = "0.28.4" diff --git a/pkgs/by-name/ya/yambar-cpu/flake.lock b/pkgs/by-name/ya/yambar-cpu/flake.lock deleted file mode 100644 index aaddd6a5..00000000 --- a/pkgs/by-name/ya/yambar-cpu/flake.lock +++ /dev/null @@ -1,61 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/pkgs/by-name/ya/yambar-cpu/flake.nix b/pkgs/by-name/ya/yambar-cpu/flake.nix deleted file mode 100644 index 3a27bccf..00000000 --- a/pkgs/by-name/ya/yambar-cpu/flake.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - description = "A smart way to check your cpu usage"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { - nixpkgs, - flake-utils, - ... - }: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages."${system}"; - in { - devShells.default = pkgs.mkShell { - packages = with pkgs; [ - # rust stuff - cargo - clippy - rustc - rustfmt - - cargo-edit - cargo-expand - ]; - }; - }); -} -# vim: ts=2 - diff --git a/pkgs/by-name/ya/yambar-cpu/package.nix b/pkgs/by-name/ya/yambar-cpu/package.nix deleted file mode 100644 index 90f1a558..00000000 --- a/pkgs/by-name/ya/yambar-cpu/package.nix +++ /dev/null @@ -1,14 +0,0 @@ -{rustPlatform}: -rustPlatform.buildRustPackage { - pname = "yambar-cpu"; - version = "0.1.0"; - - src = ./.; - cargoLock = { - lockFile = ./Cargo.lock; - }; - - meta = { - mainProgram = "cpu_usage"; - }; -} diff --git a/pkgs/by-name/ya/yambar-cpu/src/main.rs b/pkgs/by-name/ya/yambar-cpu/src/main.rs deleted file mode 100644 index 9314b81e..00000000 --- a/pkgs/by-name/ya/yambar-cpu/src/main.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::{thread, time::Duration}; - -use sysinfo::{CpuExt, System, SystemExt}; - -fn main() { - 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(); - println!( - "cpu|range:0-100|{:.0}", - cpu_usage / sys.cpus().iter().count() as f32 - ); - println!(); - - // Sleeping to give the system time to run for long - // enough to have useful information. - thread::sleep(Duration::from_secs(3)); - } -} diff --git a/pkgs/by-name/ya/yambar-cpu/update.sh b/pkgs/by-name/ya/yambar-cpu/update.sh deleted file mode 100755 index b9404867..00000000 --- a/pkgs/by-name/ya/yambar-cpu/update.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -[ "$1" = "upgrade" ] && cargo upgrade -cargo update - -# vim: ft=sh diff --git a/pkgs/by-name/ya/yambar-memory/.envrc b/pkgs/by-name/ya/yambar-memory/.envrc deleted file mode 100644 index 2f9f1a81..00000000 --- a/pkgs/by-name/ya/yambar-memory/.envrc +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -use flake diff --git a/pkgs/by-name/ya/yambar-memory/.gitignore b/pkgs/by-name/ya/yambar-memory/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/pkgs/by-name/ya/yambar-memory/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/pkgs/by-name/ya/yambar-memory/Cargo.lock b/pkgs/by-name/ya/yambar-memory/Cargo.lock deleted file mode 100644 index 6e5cb450..00000000 --- a/pkgs/by-name/ya/yambar-memory/Cargo.lock +++ /dev/null @@ -1,131 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "libc" -version = "0.2.164" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" - -[[package]] -name = "memory" -version = "0.1.0" -dependencies = [ - "sysinfo", -] - -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi", -] - -[[package]] -name = "once_cell" -version = "1.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "sysinfo" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b" -dependencies = [ - "cfg-if", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/pkgs/by-name/ya/yambar-memory/Cargo.toml b/pkgs/by-name/ya/yambar-memory/Cargo.toml deleted file mode 100644 index d67e6809..00000000 --- a/pkgs/by-name/ya/yambar-memory/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "memory" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -sysinfo = "0.28.4" diff --git a/pkgs/by-name/ya/yambar-memory/flake.lock b/pkgs/by-name/ya/yambar-memory/flake.lock deleted file mode 100644 index aaddd6a5..00000000 --- a/pkgs/by-name/ya/yambar-memory/flake.lock +++ /dev/null @@ -1,61 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/pkgs/by-name/ya/yambar-memory/flake.nix b/pkgs/by-name/ya/yambar-memory/flake.nix deleted file mode 100644 index 9182eceb..00000000 --- a/pkgs/by-name/ya/yambar-memory/flake.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - description = "A smart way to check your memory usage"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { - nixpkgs, - flake-utils, - ... - }: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages."${system}"; - in { - devShells.default = pkgs.mkShell { - packages = with pkgs; [ - # rust stuff - cargo - clippy - rustc - rustfmt - - cargo-edit - cargo-expand - ]; - }; - }); -} -# vim: ts=2 - diff --git a/pkgs/by-name/ya/yambar-memory/package.nix b/pkgs/by-name/ya/yambar-memory/package.nix deleted file mode 100644 index f3b0a50b..00000000 --- a/pkgs/by-name/ya/yambar-memory/package.nix +++ /dev/null @@ -1,14 +0,0 @@ -{rustPlatform}: -rustPlatform.buildRustPackage { - pname = "yambar-memory"; - version = "0.1.0"; - - src = ./.; - cargoLock = { - lockFile = ./Cargo.lock; - }; - - meta = { - mainProgram = "memory"; - }; -} diff --git a/pkgs/by-name/ya/yambar-memory/src/main.rs b/pkgs/by-name/ya/yambar-memory/src/main.rs deleted file mode 100644 index ea9e6f39..00000000 --- a/pkgs/by-name/ya/yambar-memory/src/main.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::{thread, time::Duration}; - -use sysinfo::{System, SystemExt}; - -fn main() { - let mut sys = System::new(); - - // Number of CPUs: - loop { - sys.refresh_memory(); - - let memory_percentage: f64 = - 100 as f64 * (sys.used_memory() as f64 / sys.total_memory() as f64); - - println!("memperc|string|{:.0}", memory_percentage); - if sys.total_swap() > 0 { - let swap_percentage: f64 = - 100 as f64 * (sys.used_swap() as f64 / sys.total_swap() as f64); - println!("swapperc|string|{:.0}", swap_percentage); - println!("swapstate|bool|true"); - } else { - println!("swapstate|bool|false"); - } - println!(""); - - // Sleeping to give the system time to run for long - // enough to have useful information. - thread::sleep(Duration::from_secs(3)); - } -} diff --git a/pkgs/by-name/ya/yambar-memory/update.sh b/pkgs/by-name/ya/yambar-memory/update.sh deleted file mode 100755 index b9404867..00000000 --- a/pkgs/by-name/ya/yambar-memory/update.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -[ "$1" = "upgrade" ] && cargo upgrade -cargo update - -# vim: ft=sh diff --git a/pkgs/by-name/ya/yambar-modules/.envrc b/pkgs/by-name/ya/yambar-modules/.envrc new file mode 100644 index 00000000..2f9f1a81 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/.envrc @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +use flake diff --git a/pkgs/by-name/ya/yambar-modules/.gitignore b/pkgs/by-name/ya/yambar-modules/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/.gitignore @@ -0,0 +1 @@ +/target diff --git a/pkgs/by-name/ya/yambar-modules/Cargo.lock b/pkgs/by-name/ya/yambar-modules/Cargo.lock new file mode 100644 index 00000000..6b689d29 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/Cargo.lock @@ -0,0 +1,131 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "libc" +version = "0.2.167" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" + +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "sysinfo" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +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-modules/Cargo.toml b/pkgs/by-name/ya/yambar-modules/Cargo.toml new file mode 100644 index 00000000..8e3995fe --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "yambar-modules" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +sysinfo = "0.28.4" diff --git a/pkgs/by-name/ya/yambar-modules/flake.lock b/pkgs/by-name/ya/yambar-modules/flake.lock new file mode 100644 index 00000000..8043448e --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1732617236, + "narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pkgs/by-name/ya/yambar-modules/flake.nix b/pkgs/by-name/ya/yambar-modules/flake.nix new file mode 100644 index 00000000..e3d0cd49 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/flake.nix @@ -0,0 +1,32 @@ +{ + description = "Extension modules for yambar(1)"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + in { + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + # rust stuff + cargo + clippy + rustc + rustfmt + + cargo-edit + cargo-expand + ]; + }; + }); +} +# vim: ts=2 + diff --git a/pkgs/by-name/ya/yambar-modules/package.nix b/pkgs/by-name/ya/yambar-modules/package.nix new file mode 100644 index 00000000..79281429 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/package.nix @@ -0,0 +1,14 @@ +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "yambar-modules"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + + meta = { + mainProgram = "yambar-modules"; + }; +} diff --git a/pkgs/by-name/ya/yambar-modules/src/cpu.rs b/pkgs/by-name/ya/yambar-modules/src/cpu.rs new file mode 100644 index 00000000..5a6dd084 --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/src/cpu.rs @@ -0,0 +1,21 @@ +use std::{thread, time::Duration}; + +use sysinfo::{CpuExt, System, SystemExt}; + +pub fn cpu() { + let mut sys = System::new(); + + loop { + sys.refresh_cpu(); + let cpu_usage: f32 = sys.cpus().iter().map(|cpu| cpu.cpu_usage()).sum(); + println!( + "cpu|range:0-100|{:.0}", + cpu_usage / sys.cpus().iter().count() as f32 + ); + println!(); + + // Sleeping to give the system time to run for long + // enough to have useful information. + thread::sleep(Duration::from_secs(3)); + } +} 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 = 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-modules/src/memory.rs b/pkgs/by-name/ya/yambar-modules/src/memory.rs new file mode 100644 index 00000000..6da714cc --- /dev/null +++ b/pkgs/by-name/ya/yambar-modules/src/memory.rs @@ -0,0 +1,29 @@ +use std::{thread, time::Duration}; + +use sysinfo::{System, SystemExt}; + +pub fn memory() { + let mut sys = System::new(); + + loop { + sys.refresh_memory(); + + let memory_percentage: f64 = + 100 as f64 * (sys.used_memory() as f64 / sys.total_memory() as f64); + + println!("memperc|string|{:.0}", memory_percentage); + if sys.total_swap() > 0 { + let swap_percentage: f64 = + 100 as f64 * (sys.used_swap() as f64 / sys.total_swap() as f64); + println!("swapperc|string|{:.0}", swap_percentage); + println!("swapstate|bool|true"); + } else { + println!("swapstate|bool|false"); + } + println!(""); + + // Sleeping to give the system time to run for long + // enough to have useful information. + thread::sleep(Duration::from_secs(3)); + } +} -- cgit 1.4.1