diff options
| -rw-r--r-- | README.md | 45 | ||||
| -rwxr-xr-x | pfetch | 83 |
2 files changed, 90 insertions, 38 deletions
@@ -21,13 +21,40 @@ _/\ __)/_) pkgs 130 ## OS support -- [x] Linux (A myriad of distributions) -- [x] MacOS -- [x] OpenBSD -- [x] FreeBSD -- [x] NetBSD -- [x] Haiku -- [x] Minix +- Linux + - Alpine Linux + - Arch Linux + - Arco Linux + - Artix Linux + - CentOS + - Debian + - Elementary + - Fedora + - Gentoo + - Guix + - Hyperbola + - KISS Linux + - Linux Lite + - Linux Mint + - Mageia + - Manjaro + - MX Linux + - NixOS + - OpenSUSE + - Parabola + - Pop!\_OS + - PureOS + - Slackware + - Ubuntu + - Void Linux +- BSD + - DragonflyBSD + - FreeBSD + - NetBSD + - OpenBSD +- MacOS +- Haiku +- Minix ## TODO @@ -61,13 +88,13 @@ _/\ __)/_) pkgs 130 # Valid: space separated string # # OFF by default: shell palette -PF_INFO="ascii title distro host kernel uptime pkgs memory" +PF_INFO="ascii title os host kernel uptime pkgs memory" # Example: Only ASCII. PF_INFO="ascii" # Example: Only Information. -PF_INFO="title distro host kernel uptime pkgs memory" +PF_INFO="title os host kernel uptime pkgs memory" # Separator between info name and info data. # Default: unset @@ -154,23 +154,27 @@ get_os() { if command -v lsb_release; then distro=$(lsb_release -sd) - # lsb_release sometimes adds quotes around the output, - # this simply remove quotes from the start/end if they - # exist. - distro=${distro##\"} - distro=${distro%%\"} - else - # Disable warning about shellcheck not being able - # to read '/etc/os-release'. This is fine. - # shellcheck source=/dev/null - . /etc/os-release && distro=$PRETTY_NAME + # This used to be a simple '. /etc/os-release' but I believe + # this is insecure as we blindly execute whatever is in the + # file. This parser instead simply handles 'key=val', treating + # the file contents as plain-text. + while IFS='=' read -r key val; do + case $key in + PRETTY_NAME) distro=$val ;; + esac + done < /etc/os-release fi + # 'os-release' and 'lsb_release' sometimes add quotes + # around the distribution name, strip them. + distro=${distro##[\"\']} + distro=${distro%%[\"\']} + # Special cases for (independent) distributions which # don't follow any os-release/lsb standards whatsoever. - command -v crux && distro=$(crux) - command -v guix && distro='Guix System' + command -v crux && distro=$(crux) + command -v guix && distro='Guix System' # Check to see if Linux is running in Windows 10 under # WSL (Windows subsystem for Linux) and append a string @@ -238,11 +242,11 @@ get_os() { distro=$(uname -sv) ;; - Minix) + Minix|DragonFly) distro="$os $kernel" - # Minix doesn't support the escape sequences used - # on exit, clear the trap. + # Minix and DragonFly don't support the escape + # sequences used, clear the exit trap. trap '' EXIT ;; @@ -288,7 +292,7 @@ get_host() { host="$name $version $model" ;; - Darwin*|FreeBSD*) + Darwin*|FreeBSD*|DragonFly*) host=$(sysctl -n hw.model) ;; @@ -353,7 +357,7 @@ get_uptime() { IFS=. read -r s _ < /proc/uptime ;; - Darwin*|*BSD*) + Darwin*|*BSD*|DragonFly*) s=$(sysctl -n kern.boottime) # Extract the uptime in seconds from the following output: @@ -417,7 +421,6 @@ get_pkgs() { case $os in Linux*) # Commands which print packages one per line. - has kiss && kiss l has bonsai && bonsai list has pacman-key && pacman -Qq has dpkg && dpkg-query -f '.\n' -W @@ -427,6 +430,7 @@ get_pkgs() { has guix && guix package --list-installed # Directories containing packages. + has kiss && printf '%s\n' /var/db/kiss/installed/*/ has brew && printf '%s\n' "$(brew --cellar)/"* has emerge && printf '%s\n' /var/db/pkg/*/*/ has pkgtool && printf '%s\n' /var/log/packages/* @@ -447,7 +451,7 @@ get_pkgs() { has brew && printf '%s\n' /usr/local/Cellar/* ;; - FreeBSD*) + FreeBSD*|DragonFly*) pkg info ;; @@ -479,7 +483,7 @@ get_pkgs() { get_memory() { case $os in - # Used memory is calculated using the following "formula" (Linux): + # Used memory is calculated using the following "formula": # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable # Source: https://github.com/KittyKatt/screenFetch/issues/386 Linux*) @@ -507,7 +511,7 @@ get_memory() { mem_full=$((mem_full / 1024)) ;; - # Used memory is calculated using the following "formula" (MacOS): + # Used memory is calculated using the following "formula": # (wired + active + occupied) * 4 / 1024 Darwin*) mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) @@ -557,9 +561,9 @@ get_memory() { EOF ;; - # Used memory is calculated using the following "formula" (FreeBSD): - # (inactive_count + free_count + cache_count) * page_size / 1024 - FreeBSD*) + # Used memory is calculated using the following "formula": + # mem_full - ((inactive + free + cache) * page_size / 1024) + FreeBSD*|DragonFly*) mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) # Use 'set --' to store the output of the command in the @@ -581,7 +585,7 @@ get_memory() { # $2: vm.stats.vm.v_inactive_count # $3: vm.stats.vm.v_free_count # $4: vm.stats.vm.v_cache_count - mem_used=$((($2 + $3 + $4) * $1 / 1024 / 1024)) + mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024))) ;; NetBSD*) @@ -589,7 +593,7 @@ get_memory() { # NetBSD implements a lot of the Linux '/proc' filesystem, # this uses the same parser as the Linux memory detection. - while IFS=:k read -r key val _; do + while IFS=':k ' read -r key val _; do case $key in MemFree) mem_free=$((val / 1024)) @@ -772,7 +776,7 @@ get_ascii() { EOF ;; - [Dd]ragonfly*) + [Dd]ragon[Ff]ly*) read_ascii 1 <<-EOF ,${c1}_${c7}, ('-_${c1}|${c7}_-') @@ -1062,6 +1066,27 @@ get_ascii() { EOF ;; + [Ss]un[Oo][Ss]) + read_ascii 3 <<-EOF + ${c3} . .; . + . :; :: ;: . + .;. .. .. .;. + .. .. .. .. + .;, ,;. + EOF + ;; + + [Uu]buntu*) + read_ascii 3 <<-EOF + ${c3} _ + ---(_) + _/ --- \\ + (_) | | + \\ --- _/ + ---(_) + EOF + ;; + [Vv]oid*) read_ascii 2 <<-EOF ${c2} _______ @@ -1116,10 +1141,10 @@ get_ascii() { # Add a gap between the ascii art and the information. ascii_width=$((ascii_width + 4)) - # Minix doesn't support these! + # Minix and DragonFly don't support these! # '[?7l': Disable line-wrapping. # '[?25l': Hide the cursor. - [ "$os" != Minix ] && + [ "$os" != Minix ] && [ "$os" != DragonFly ] && printf '[?7l[?25l' >&6 # Print the ascii art and position the cursor back where we |
