Skip to content
Merged
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
92 changes: 91 additions & 1 deletion Cargo.lock

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

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

[dependencies]
libc = "0.2"
rpm-pkg-count = { version = "0.2.1", features = ["runtime"] }


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

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


4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -15,6 +15,8 @@ Download from [actions](https://github.com/charleschetty/ccfetch/actions/workflo
> You should install [rust](https://www.rust-lang.org/tools/install) first

```shell
# If using a Fedora kernel, first (optionally)
sudo dnf install rpm-devel
git clone https://github.com/charleschetty/ccfetch
cd ccfetch
cargo build --release
Expand Down
22 changes: 10 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,22 +430,19 @@ 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)",
)),
}
}


pub fn get_uptime() -> Result<String, String> {
let uptime_info = match fs::read_to_string("/proc/uptime") {
Ok(info) => info,
Expand Down
Loading