diff options
Diffstat (limited to 'pkgs/by-name/ya')
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/.gitignore | 1 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/Cargo.lock | 191 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/Cargo.toml | 9 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/flake.lock | 123 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/flake.nix | 35 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/package.nix | 10 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-cpu/src/main.rs | 22 | ||||
-rwxr-xr-x | pkgs/by-name/ya/yambar-cpu/update.sh | 7 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/.gitignore | 1 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/Cargo.lock | 191 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/Cargo.toml | 9 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/flake.lock | 123 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/flake.nix | 35 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/package.nix | 10 | ||||
-rw-r--r-- | pkgs/by-name/ya/yambar-memory/src/main.rs | 30 | ||||
-rwxr-xr-x | pkgs/by-name/ya/yambar-memory/update.sh | 7 |
16 files changed, 804 insertions, 0 deletions
diff --git a/pkgs/by-name/ya/yambar-cpu/.gitignore b/pkgs/by-name/ya/yambar-cpu/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/.gitignore @@ -0,0 +1 @@ +/target diff --git a/pkgs/by-name/ya/yambar-cpu/Cargo.lock b/pkgs/by-name/ya/yambar-cpu/Cargo.lock new file mode 100644 index 00000000..c9f2e156 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/Cargo.lock @@ -0,0 +1,191 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpu_usage" +version = "0.1.0" +dependencies = [ + "sysinfo", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ntapi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc" +dependencies = [ + "winapi", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "rayon" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sysinfo" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a81bbc26c485910df47772df6bbcdb417036132caa9e51e29d2e39c4636d4e" +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 new file mode 100644 index 00000000..5a2bc6f9 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/Cargo.toml @@ -0,0 +1,9 @@ +[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.1" diff --git a/pkgs/by-name/ya/yambar-cpu/flake.lock b/pkgs/by-name/ya/yambar-cpu/flake.lock new file mode 100644 index 00000000..63ad6a9b --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/flake.lock @@ -0,0 +1,123 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1677892403, + "narHash": "sha256-/Wi0L1spSWLFj+UQxN3j0mPYMoc7ZoAujpUF/juFVII=", + "owner": "ipetkov", + "repo": "crane", + "rev": "105e27adb70a9890986b6d543a67761cbc1964a2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1677852945, + "narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677812689, + "narHash": "sha256-EakqhgRnjVeYJv5+BJx/NZ7/eFTMBxc4AhICUNquhUg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "e53e8853aa7b0688bc270e9e6a681d22e01cf299", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "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 new file mode 100644 index 00000000..0d63e121 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/flake.nix @@ -0,0 +1,35 @@ +{ + description = "A smart way to check your cpu usage"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane.url = "github:ipetkov/crane"; + crane.inputs.nixpkgs.follows = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + crane, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + craneLib = crane.lib.${system}; + craneBuild = craneLib.buildPackage { + src = craneLib.cleanCargoSource ./.; + + doCheck = true; + }; + in { + packages.default = craneBuild; + legacyPackages.default = craneBuild; + app.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/cpu_usage"; + }; + }); +} +# vim: ts=2 + diff --git a/pkgs/by-name/ya/yambar-cpu/package.nix b/pkgs/by-name/ya/yambar-cpu/package.nix new file mode 100644 index 00000000..d054a970 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/package.nix @@ -0,0 +1,10 @@ +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "yambar_cpu"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; +} diff --git a/pkgs/by-name/ya/yambar-cpu/src/main.rs b/pkgs/by-name/ya/yambar-cpu/src/main.rs new file mode 100644 index 00000000..9314b81e --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/src/main.rs @@ -0,0 +1,22 @@ +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 new file mode 100755 index 00000000..4de6e712 --- /dev/null +++ b/pkgs/by-name/ya/yambar-cpu/update.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +[ "$1" = "upgrade" ] && cargo upgrade + +cargo update + +# vim: ft=sh diff --git a/pkgs/by-name/ya/yambar-memory/.gitignore b/pkgs/by-name/ya/yambar-memory/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/.gitignore @@ -0,0 +1 @@ +/target diff --git a/pkgs/by-name/ya/yambar-memory/Cargo.lock b/pkgs/by-name/ya/yambar-memory/Cargo.lock new file mode 100644 index 00000000..9fb53b05 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/Cargo.lock @@ -0,0 +1,191 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "crossbeam-channel" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory" +version = "0.1.0" +dependencies = [ + "sysinfo", +] + +[[package]] +name = "ntapi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc" +dependencies = [ + "winapi", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "rayon" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sysinfo" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a81bbc26c485910df47772df6bbcdb417036132caa9e51e29d2e39c4636d4e" +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 new file mode 100644 index 00000000..27ab3c31 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/Cargo.toml @@ -0,0 +1,9 @@ +[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.1" diff --git a/pkgs/by-name/ya/yambar-memory/flake.lock b/pkgs/by-name/ya/yambar-memory/flake.lock new file mode 100644 index 00000000..1b495c04 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/flake.lock @@ -0,0 +1,123 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1677642623, + "narHash": "sha256-GlRa6/HWg8mIxPM29ZuTP2dP8y9sQ6BdbrjzCO8JgAo=", + "owner": "ipetkov", + "repo": "crane", + "rev": "f3f763e4d9f156ec0c37f39b0f77e2d62213b296", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1677816901, + "narHash": "sha256-oqe8Q9LlWNGfVfUDkKfpWAk+I9RRDBvMSyYVIOZCfPM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0749042bfaa2f4efa70ac829c5387133cfc0a337", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1676437770, + "narHash": "sha256-mhJye91Bn0jJIE7NnEywGty/U5qdELfsT8S+FBjTdG4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "a619538647bd03e3ee1d7b947f7c11ff289b376e", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "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 new file mode 100644 index 00000000..186195cc --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/flake.nix @@ -0,0 +1,35 @@ +{ + description = "A smart way to check your cpu usage"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane.url = "github:ipetkov/crane"; + crane.inputs.nixpkgs.follows = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + crane, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + craneLib = crane.lib.${system}; + craneBuild = craneLib.buildPackage { + src = craneLib.cleanCargoSource ./.; + + doCheck = true; + }; + in { + packages.default = craneBuild; + legacyPackages.default = craneBuild; + app.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/memory"; + }; + }); +} +# vim: ts=2 + diff --git a/pkgs/by-name/ya/yambar-memory/package.nix b/pkgs/by-name/ya/yambar-memory/package.nix new file mode 100644 index 00000000..a144dc4c --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/package.nix @@ -0,0 +1,10 @@ +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "yambar_memory"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; +} diff --git a/pkgs/by-name/ya/yambar-memory/src/main.rs b/pkgs/by-name/ya/yambar-memory/src/main.rs new file mode 100644 index 00000000..ea9e6f39 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/src/main.rs @@ -0,0 +1,30 @@ +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 new file mode 100755 index 00000000..4de6e712 --- /dev/null +++ b/pkgs/by-name/ya/yambar-memory/update.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +[ "$1" = "upgrade" ] && cargo upgrade + +cargo update + +# vim: ft=sh |