From cf56068cff6523f794b636b74b163c6eb067eaf7 Mon Sep 17 00:00:00 2001 From: Sisyphus1813 Date: Wed, 9 Jul 2025 17:34:35 -0400 Subject: [PATCH 1/2] Performance Updates - Fixed poor performance on Fedora systems due to Command calls. Replaced with rpm_pkg-count which decreased render time on Fedora systems from about 200ms to 5ms (about twice as fast as fastfetch, on average). --- Cargo.lock | 92 +++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 +- README.md | 2 +- src/info/info.rs | 21 +++++------ 4 files changed, 102 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f56c99b..53bce31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,106 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ccfetch" version = "0.1.0" dependencies = [ "libc", + "rpm-pkg-count", ] +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + [[package]] name = "libc" version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "rpm-pkg-count" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a03ac5d470b2b2bd9ed4493c2bb929f6a04371455b457f419148c79e830f0cb" +dependencies = [ + "libloading", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" diff --git a/Cargo.toml b/Cargo.toml index 1dd603c..1c41fa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] libc = "0.2" +rpm-pkg-count = { version = "0.2.1", features = ["runtime"] } [profile.release] @@ -18,5 +19,3 @@ codegen-units = 1 [build] rustflags = ["-C", "target-cpu=native"] - - diff --git a/README.md b/README.md index 9d26832..fe1f49a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A neofetch like system information tool written in rust. Which is super fast, ev ![screenshot](/screenshots/screenshot1.png) -Currently, ccfetch only supports Arch, Debian, and Ubuntu, but the logo will be displayed as ["TUX"](https://en.wikipedia.org/wiki/Tux_(mascot)) if you use other distributions +Currently, ccfetch only supports Arch, Debian, Fedora, and Ubuntu, but the logo will be displayed as ["TUX"](https://en.wikipedia.org/wiki/Tux_(mascot)) if you use other distributions ## Installation diff --git a/src/info/info.rs b/src/info/info.rs index 0856642..e6aa1d6 100644 --- a/src/info/info.rs +++ b/src/info/info.rs @@ -5,6 +5,7 @@ use std::os::raw::c_char; use std::path::PathBuf; use std::{ffi::CString, fs::File, path::Path}; use std::{fs, mem}; +use rpm_pkg_count::count; use crate::tools::get_parent; use crate::tools::pci::{get_device_name_pci, get_gpu_vendor_name, read_pci_devices_and_find_gpu}; @@ -429,19 +430,15 @@ pub fn count_dpkg() -> io::Result { return Ok(format!("{} (dpkg)", count)); } -pub fn count_rpm() -> std::io::Result { - use std::process::Command; - let output = Command::new("rpm").arg("-qa").output()?; +pub fn count_rpm() -> io::Result { + let pkg_count = unsafe { count() }; - if output.status.success() { - let stdout = String::from_utf8_lossy(&output.stdout); - let count = stdout.lines().count(); - Ok(format!("{} (rpm)", count)) - } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "rpm command failed", - )) + match pkg_count { + Some(n) => Ok(n.to_string()), + None => Err(io::Error::new( + io::ErrorKind::Other, + "Could not count RPM packages (librpm unavailable)", + )), } } From 21d36826e88930193ef41e196a22b4c39b890ebc Mon Sep 17 00:00:00 2001 From: Sisyphus1813 Date: Wed, 9 Jul 2025 18:04:07 -0400 Subject: [PATCH 2/2] Quick fix - Additional fixes to README.nd & cargo.toml regarding dependencies. --- Cargo.lock | 82 +++--------------------------------------------------- Cargo.toml | 3 +- README.md | 5 +++- 3 files changed, 9 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53bce31..fc91950 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,12 +10,6 @@ dependencies = [ "rpm-pkg-count", ] -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - [[package]] name = "libc" version = "0.2.150" @@ -23,14 +17,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] -name = "libloading" -version = "0.8.8" +name = "pkg-config" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" -dependencies = [ - "cfg-if", - "windows-targets", -] +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "rpm-pkg-count" @@ -38,69 +28,5 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a03ac5d470b2b2bd9ed4493c2bb929f6a04371455b457f419148c79e830f0cb" dependencies = [ - "libloading", + "pkg-config", ] - -[[package]] -name = "windows-targets" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" - -[[package]] -name = "windows_i686_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" - -[[package]] -name = "windows_i686_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" diff --git a/Cargo.toml b/Cargo.toml index 1c41fa4..1320896 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,7 @@ edition = "2021" [dependencies] libc = "0.2" -rpm-pkg-count = { version = "0.2.1", features = ["runtime"] } - +rpm-pkg-count = { version = "0.2.1", features = ["compile-time"] } [profile.release] opt-level = 3 diff --git a/README.md b/README.md index fe1f49a..a4cf1e3 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,12 @@ Download from [actions](https://github.com/charleschetty/ccfetch/actions/workflo ### Build from source -> You should install [rust](https://www.rust-lang.org/tools/install) first +> You should install [rust](https://www.rust-lang.org/tools/install) first. ```shell +# If using a Fedora kernel, first +sudo dnf install rpm-devel +# otherwise git clone https://github.com/charleschetty/ccfetch cd ccfetch cargo build --release