Giter VIP home page Giter VIP logo

pfetch-rs's Introduction

pfetch-rs

A rewrite of the pfetch system information tool by dylanaraps in Rust


About

If you are familiar with the pfetch system information tool by dylanaraps, this does the exact same thing, but with an about 10x faster runtime. pfetch is simple by design with some (but not many) configuration options and a minimalistic look.

Supported Platforms: Linux, Android, macOS, Windows, FreeBSD, NetBSD

Included Logos: Alma Linux (new), Alpine Linux, Android, AmogOS (new), Arch Linux, ArcoLinux, Artix Linux, Bazzite (new), Bedrock Linux, Buildroot, CelOS, CentOS, Crystal Linux, dahliaOS, Debian, Devuan, DietPi (new), DragonflyBSD, Elementary OS, EndeavourOS, Fedora, Fiwix (new), FreeBSD, Garuda Linux, Gentoo Linux, Gnu, Guix, Haiku, HydroOS, Hyperbola, instantOS, IRIX, KDE neon, Linux Lite, Linux, Mint, macOS, Mageia, Manjaro, Minix, MorphOS (new), MX Linux, NetBSD, NixOS, Nobara Project (new), OpenBSD, openSUSE Tumbleweed, openSUSE Leap, OpenWrt, Oracle Linux (new), Parabola, Pop!_OS (updated), PureOS, Raspbian, Rocky Linux (new), SerenityOS, Slackware, Solus, SteamOS (new), Solaris, Ubuntu, Vanilla OS (new), Void Linux, Windows (new), Xeonix Linux

You can check out how they look here.

For all other distributions, a penguin will be displayed.

Credit to the original pfetch and its contributors.

If you want a logo to be added, feel free to open an issue or a PR.

Installation

Note: On openSUSE, install the rpm-devel package for faster package count.

Binary

Download a binary from the latest release.

Cargo

cargo install pfetch

Homebrew

brew install pfetch-rs

Nixpkgs

Install the pfetch-rs Nix package.

AUR

Install the pfetch-rs or pfetch-rs-bin AUR package.

Performance

Benchmarks performed on an AMD Ryzen 5 3600. Execution time is measured using hyperfine with -w 4 -m 500 -N flags.

Implementation Mean [ms] Min [ms] Max [ms]
POSIX sh (bash) 23.7 ± 0.9 22.3 29.3
POSIX sh (dash) 15.9 ± 0.3 15.1 18.2
Rust (v2.3.0) 2.2 ± 0.2 1.8 3.9

Note: This is with pacman and flatpak being the only installed package managers. For more info, see Improving Performance.

Improving Performance

The by far slowest part of the pfetch execution time is counting the installed packages. For most package managers this is still very fast, but there are some (currently nix (and zypper, if rpm-devel is not installed)) that take ~500ms to report installed packages, which takes away all performance benefits of the Rust version. If you have one or more of these installed, you can skip counting them by setting the PF_FAST_PKG_COUNT environment variable to any value.

Configuration

Like the original pfetch, pfetch-rs is configured through environment variables. Your existing config will probably still work, the main difference is how padding is configured.

If you want to display a custom logo, use the PF_CUSTOM_LOGOS option, an example for a custom logos file can be found below.

# Which information to display.
# Default: first example below
# Valid: space separated string
#
# OFF by default: shell editor wm de palette cpu
PF_INFO="ascii title os host kernel uptime pkgs memory"

# Example: Only ASCII.
PF_INFO="ascii"

# Example: Only Information.
PF_INFO="title os host kernel uptime pkgs memory"

# A file containing environment variables to source before running pfetch
# Default: unset
# Valid: A shell script
PF_SOURCE=""

# A file containing pfetch logos to overwrite default logos or add new logos
# Default: unset
# Valid: Path to a file containing pfetch logos (example below)
PF_CUSTOM_LOGOS="~/.config/pfetch_logos"

# Separator between info name and info data.
# Default: unset
# Valid: string
PF_SEP=":"

# Enable/Disable colors in output:
# Default: 1
# Valid: 1 (enabled), 0 (disabled)
PF_COLOR=1

# Color of info names:
# Default: unset (auto)
# Valid: 0-9
PF_COL1=4

# Color of info data:
# Default: unset (auto)
# Valid: 0-9
PF_COL2=9

# Color of title data:
# Default: unset (auto)
# Valid: 0-9, COL1 (copies COL1 value)
PF_COL3=1

# Alignment paddings (this is different to the original version).
# Default: unset (auto)
# Valid: int
PF_PAD1=""
PF_PAD2=""
PF_PAD3=""

# Which ascii art to use.
# Default: unset (auto)
# Valid: string
PF_ASCII="openbsd"

# The below environment variables control more
# than just 'pfetch' and can be passed using
# 'HOSTNAME=cool_pc pfetch' to restrict their
# usage solely to 'pfetch'.

# Which user to display.
USER=""

# Which hostname to display.
HOSTNAME=""

# Skip package managers that take "long" to query package count (like nix)
PF_FAST_PKG_COUNT=1

A file containing custom pfetch logos could look like this (also found under custom_logos_example). This will turn the Arch Linux logo red, the Debian Logo blue and the Fedora logo yellow:

[Aa]rch*)
	read_ascii 1 <<- EOF
			${c1}       /\\
			${c1}      /  \\
			${c1}     /\\   \\
			${c1}    /      \\
			${c1}   /   ,,   \\
			${c1}  /   |  |  -\\
			${c1} /_-''    ''-_\\
		EOF
	;;
[Dd]ebian*)
	read_ascii 4 <<- EOF
			${c4}  _____
			${c4} /  __ \\
			${c4}|  /    |
			${c4}|  \\___-
			${c4}-_
			${c4}  --_
		EOF
	;;
[Ff]edora*)
    read_ascii 3 <<- EOF
			        ${c3},'''''.
			       ${c3}|   ,.  |
			       ${c3}|  |  '_'
			${c3}  ,....|  |..
			${c3}.'  ,_;|   ..'
			${c3}|  |   |  |
			${c3}|  ',_,'  |
			${c3} '.     ,'
			   ${c3}'''''
		EOF

Note: Make sure to use tabs for indentation and separate logos with ;;, as seen above. You only need to add the logos you want to overwrite/add, the default logos will stay available. The included logos can be found at ./pfetch-extractor/logos.sh.

pfetch-rs's People

Contributors

21st-centuryman avatar dependabot[bot] avatar github-actions[bot] avatar gobidev avatar rmsthebest avatar rubixdev avatar un1q32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pfetch-rs's Issues

Colors are darker on Windows Terminal

IIRC some terminals treat bold text as always being bright, so I assume this is a result of the text not being bold in pfetch-rs

Screenshot (24)

ignore the title that's a result of PF_COL3="COL1" not being supported in the original pfetch

SteamOS ASCII

Would be nice to have an ASCII logo on my Steam Deck besides the tux

Custom ASCII Art

How do you add custom ASCII art when you install pfetch-rs via Homebrew? I want to use another fedora logo from ufetch. I've checked in the cellar from brew to see if there are any files that contain ASCII art but there is none. There is not even a single file from this git repository in the Brew Cellar. I might not know how Homebrew works properly? @Gobidev

Fails to run on Windows 10

with RUST_BACKTRACE=full

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." })', src\main.rs:207:38
stack backtrace:
   0:     0x7ff6a60ecde2 - <unknown>
   1:     0x7ff6a610597b - <unknown>
   2:     0x7ff6a60e993a - <unknown>
   3:     0x7ff6a60ecb2b - <unknown>
   4:     0x7ff6a60ef2b9 - <unknown>
   5:     0x7ff6a60eef3b - <unknown>
   6:     0x7ff6a60efb50 - <unknown>
   7:     0x7ff6a60ef8de - <unknown>
   8:     0x7ff6a60ed7ff - <unknown>
   9:     0x7ff6a60ef590 - <unknown>
  10:     0x7ff6a6112845 - <unknown>
  11:     0x7ff6a6112d66 - <unknown>
  12:     0x7ff6a604433e - <unknown>
  13:     0x7ff6a6045826 - <unknown>
  14:     0x7ff6a604837c - <unknown>
  15:     0x7ff6a60e5ffe - <unknown>
  16:     0x7ff6a6044d9c - <unknown>
  17:     0x7ff6a610d1d0 - <unknown>
  18:     0x7ff8c64f7604 - BaseThreadInitThunk
  19:     0x7ff8c71826a1 - RtlUserThreadStart

Embed the logos in the binary

Im not that experienced in rust but wouldnt it be better to embed the strings in the binary with include_str!
something like this

const ARCH = include_str!(#"
				       /\\
				      /  \\
				     /\\   \\
				    /      \\
			           /   ,,   \\
				  /   |  |  -\\
				 /_-''    ''-_\\"#);
const ARCO = include_str!(#" 
				      /\\
				     /  \\
				    / /\\ \\
				   / /  \\ \\
				  / /    \\ \\
				 / / _____\\ \\
				/_/  \`----.\\_\\"#);

match distro {
     "arch" => ARCH,
     "arco" => ARCO
};

(I wrote this in github's editor ignore any mistakes in the code)

Feat: Homebrew package

This will act as a little log/discussion for now for the attempts made to make this package part of Homebrew's core package.

Currently the repository needs to be 30 or more days before it is added to Homebrew-core, which it is yet to reach.

In the mean time if you'd like to try this package through homebrew, I have made it part of my personal tap:

brew install 21stcenturyman/homebrew-21st/pfetch-rs

or

brew tap 21stcenturyman/homebrew-21st
brew install pfetch-rs

Linux: OpenSUSE package count

pfetch-rs only shows how many flatpaks I have installed rather than how many packages I have installed from different package managers

Android os detection fails

Screenshot_20230315-141919.png

Also the kernel version should stop at the end of the line instead of wrapping around like it does currently

ASCII not detected on MacOS

running pfetch on my M1 Mac

uname -mrv
22.3.0 Darwin Kernel Version 22.3.0: Thu Jan  5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000 arm64

results in the following output:

    ___      USER@HOSTNAME
   (.. |     host   arm64
   (<> |     kernel 22.3.0
  / __  \    uptime 3d 18h 55m
 ( /  \ /|   pkgs   0
_/\ __)/_)   memory 15441M / 32768M
\/-____\/

when i manually set PF_ASCII to "macos" it gives the correct ascii logo for MacOS
also pkgs should probably track brew by default.

Logo for Oracle Linux

Hello. Thank you for your project. I have a request. Could you include in your project support for Oracle Linux?

Here is the link for official website.

Thank you.

Windows: Can't download binary

Currently running win 11 23H2:
image

no matter how I've tried same "Virus detected" error appears on every browser I use:
image

yes, even tried download on my VPS, local server and even CasaOS host:
image

any idea why?

bedrock linux isn't detected

running the pfetch-rs on bedrock linux shows only the stratum (the distribution running on top of bedrock) it's running from.
looking at the source code i see no mention of bedrock, bedrock needs to be handled specially since it isn't a distro but meta distro allowing to run other distros on top of it.
the original pfetch does detect bedrock by checking if PATH env contains "/bedrock/cross/", i guess just checking if that something like "/bedrock/etc/os-release" exists would also be sufficient, nevermind that would still show bedrock even with strat -r option (hiding the bedrock from enviroment)

Option to disable nix packages being counted

If you have the nix package manager installed and are on a distro other than nix, disabling them being counted will result in a much faster execution time with only a slight inaccuracy of the package count.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.