Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
libc = "0.2"

rpm-pkg-count = { version = "0.2.1", features = ["compile-time"] }

[profile.release]
opt-level = 3
Expand All @@ -18,5 +18,3 @@ codegen-units = 1

[build]
rustflags = ["-C", "target-cpu=native"]


7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ 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

Download from [actions](https://github.com/charleschetty/ccfetch/actions/workflows/build.yml)

### 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
Expand Down
21 changes: 9 additions & 12 deletions src/info/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -429,19 +430,15 @@ pub fn count_dpkg() -> io::Result<String> {
return Ok(format!("{} (dpkg)", count));
}

pub fn count_rpm() -> std::io::Result<String> {
use std::process::Command;
let output = Command::new("rpm").arg("-qa").output()?;
pub fn count_rpm() -> io::Result<String> {
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)",
)),
}
}

Expand Down