From c9b4d260840a4afb44e6803cc987ca80bf5c4d64 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 3 Nov 2019 00:43:07 +0000 Subject: [PATCH 01/73] pfetch: print without cursor movement --- pfetch | 135 ++++++++++----------------------------------------------- 1 file changed, 23 insertions(+), 112 deletions(-) diff --git a/pfetch b/pfetch index 98dbef4..8bf5dfc 100755 --- a/pfetch +++ b/pfetch @@ -3,59 +3,6 @@ # pfetch - Simple POSIX sh fetch script. log() { - # The 'log()' function handles the printing of information. - # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info - # happen independently of each other. - # - # The size of the ascii art is stored and the ascii is printed first. - # Once the ascii is printed, the cursor is located right below the art - # (See marker $[1]). - # - # Using the stored ascii size, the cursor is then moved to marker $[2]. - # This is simply a cursor up escape sequence using the "height" of the - # ascii art. - # - # 'log()' then moves the cursor to the right the "width" of the ascii art - # with an additional amount of padding to add a gap between the art and - # the information (See marker $[3]). - # - # When 'log()' has executed, the cursor is then located at marker $[4]. - # When 'log()' is run a second time, the next line of information is - # printed, moving the cursor to marker $[5]. - # - # Markers $[4] and $[5] repeat all the way down through the ascii art - # until there is no more information left to print. - # - # Every time 'log()' is called the script keeps track of how many lines - # were printed. When printing is complete the cursor is then manually - # placed below the information and the art according to the "heights" - # of both. - # - # The math is simple: move cursor down $((ascii_height - info_height)). - # If the aim is to move the cursor from marker $[5] to marker $[6], - # plus the ascii height is 8 while the info height is 2 it'd be a move - # of 6 lines downwards. - # - # However, if the information printed is "taller" (takes up more lines) - # than the ascii art, the cursor isn't moved at all! - # - # Once the cursor is at marker $[6], the script exits. This is the gist - # of how this "dynamic" printing and layout works. - # - # This method allows ascii art to be stored without markers for info - # and it allows for easy swapping of info order and amount. - # - # $[2] ___ $[3] goldie@KISS - # $[4](.· | $[5] os KISS Linux - # (<> | - # / __ \ - # ( / \ /| - # _/\ __)/_) - # \/-____\/ - # $[1] - # - # $[6] /home/goldie $ - # End here if no data was found. [ "$2" ] || return @@ -75,27 +22,9 @@ log() { info=$* } - # Move the cursor to the right, the width of the ascii art with an - # additional gap for text spacing. - printf '[%sC' "${ascii_width--1}" - - # Print the info name and color the text. - printf '[3%s;1m%s' "${PF_COL1-4}" "$name" - - # Print the info name and info data separator. - printf '%s' "$PF_SEP" + align=$(printf '%*.s' "$((${#name}-info_length))" "") - # Move the cursor backward the length of the *current* info name and - # then move it forwards the length of the *longest* info name. This - # aligns each info data line. - printf '[%sD[%sC' "${#name}" "${PF_ALIGN-$info_length}" - - # Print the info data, color it and strip all leading whitespace - # from the string. - printf '[3%sm%s\n' "${PF_COL2-7}" "$info" - - # Keep track of the number of times 'log()' has been run. - info_height=$((${info_height:-0} + 1)) + out="[3${PF_COL1-4};1m${name}${PF_SEP}${align}[3${PF_COL2-7}m${info}" } get_title() { @@ -112,7 +41,7 @@ get_title() { # shellcheck disable=SC2039 hostname=${HOSTNAME:-${hostname:-$(hostname)}} - log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 + log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " } get_os() { @@ -123,7 +52,7 @@ get_os() { # On first run, this function displays _nothing_, only on the second # invocation is 'log()' called. [ "$distro" ] && { - log os "$distro" >&6 + log os "$distro" return } @@ -283,7 +212,7 @@ get_kernel() { *) # '$kernel' is the cached output of 'uname -r'. - log kernel "$kernel" >&6 + log kernel "$kernel" ;; esac } @@ -354,7 +283,7 @@ get_host() { done # '$arch' is the cached output from 'uname -m'. - log host "${host:-$arch}" >&6 + log host "${host:-$arch}" } get_uptime() { @@ -409,7 +338,7 @@ get_uptime() { [ "$h" = 0 ] || uptime="${uptime}${h}h " [ "$m" = 0 ] || uptime="${uptime}${m}m " - log uptime "${uptime:-0m}" >&6 + log uptime "${uptime:-0m}" } get_pkgs() { @@ -509,7 +438,7 @@ get_pkgs() { esac | wc -l ` - [ "$packages" -gt 1 ] && log pkgs "$packages" >&6 + [ "$packages" -gt 1 ] && log pkgs "$packages" } get_memory() { @@ -691,7 +620,7 @@ get_memory() { ;; esac - log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 + log memory "${mem_used:-?}M / ${mem_full:-?}M" } get_wm() { @@ -820,7 +749,7 @@ get_wm() { ;; esac - log wm "$wm" >&6 + log wm "$wm" } @@ -831,18 +760,18 @@ get_de() { # # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, # display the value of '$DESKTOP_SESSION'. - log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6 + log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" } get_shell() { # Display the basename of the '$SHELL' environment variable. - log shell "${SHELL##*/}" >&6 + log shell "${SHELL##*/}" } get_editor() { # Display the value of '$VISUAL', if it's empty, display the # value of '$EDITOR'. - log editor "${VISUAL:-$EDITOR}" >&6 + log editor "${VISUAL:-$EDITOR}" } get_palette() { @@ -1324,8 +1253,6 @@ get_ascii() { # information. The 'sed' is used to strip 'm' color codes from # the ascii art so they don't affect the width variable. while read -r line; do - ascii_height=$((${ascii_height:-0} + 1)) - # This was a ternary operation but they aren't supported in # Minix's shell. [ "${#line}" -gt "${ascii_width:-0}" ] && @@ -1341,13 +1268,6 @@ get_ascii() { # Add a gap between the ascii art and the information. ascii_width=$((ascii_width + 4)) - - # Print the ascii art and position the cursor back where we - # started prior to printing it. - # '[1m': Print the ascii in bold. - # '[m': Clear bold. - # '[%sA': Move the cursor up '$ascii_height' amount of lines. - printf '%s[%sA' "$ascii" "$ascii_height" >&6 } main() { @@ -1414,6 +1334,8 @@ main() { set -f set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} + case $* in *ascii*) get_ascii; shift; esac + # Iterate over the info functions to determine the lengths of the # "info names" for output alignment. The option names and subtitles # match 1:1 so this is thankfully simple. @@ -1429,26 +1351,15 @@ main() { # Add an additional space of length to act as a gap. info_length=$((info_length + 1)) - # Iterate over the above list and run any existing "get_" functions. - for info; do "get_$info"; done + while IFS= read -r line; do + "get_$1" + shift "$(($# ? 1 : 0))" + printf '%*.s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 + out= + done <<-EOF + $ascii + EOF } - - # Position the cursor below both the ascii art and information lines - # according to the height of both. If the information exceeds the ascii - # art in height, don't touch the cursor (0/unset), else move it down - # N lines. - # - # This was a ternary operation but they aren't supported in Minix's shell. - [ "${info_height:-0}" -lt "${ascii_height:-0}" ] && - cursor_pos=$((ascii_height - info_height)) - - # Print '$cursor_pos' amount of newlines to correctly position the - # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only - # typically available (by default) on GNU based systems! - while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do - printf '\n' - i=$((i + 1)) - done >&6 } main "$@" From a1bbe9749c9a934d768d57f2bbdc20a92448d247 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 3 Nov 2019 00:45:53 +0000 Subject: [PATCH 02/73] pfetch: fix bugs --- pfetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 8bf5dfc..46d72a1 100755 --- a/pfetch +++ b/pfetch @@ -1334,7 +1334,7 @@ main() { set -f set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} - case $* in *ascii*) get_ascii; shift; esac + case $@ in *ascii*) get_ascii; shift; esac # Iterate over the info functions to determine the lengths of the # "info names" for output alignment. The option names and subtitles @@ -1351,7 +1351,7 @@ main() { # Add an additional space of length to act as a gap. info_length=$((info_length + 1)) - while IFS= read -r line; do + while IFS= read -r line || [ "$1" ]; do "get_$1" shift "$(($# ? 1 : 0))" printf '%*.s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 From 24498852fd8f79d35f8e84e554e0f312b851f95f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 3 Nov 2019 01:42:45 +0000 Subject: [PATCH 03/73] pfetch: minor fixes --- pfetch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 46d72a1..80661cd 100755 --- a/pfetch +++ b/pfetch @@ -1031,7 +1031,7 @@ get_ascii() { [Ll]inux*) read_ascii 4 <<-EOF ${c4} ___ - (${c7}.· ${c4}| + (${c7}.. ${c4}| (${c5}<> ${c4}| / ${c7}__ ${c4}\\ ( ${c7}/ \\ ${c4}/| @@ -1334,6 +1334,8 @@ main() { set -f set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} + # Grab the ascii art if the user has enabled it. This simply + # populates the '$ascii' variable. case $@ in *ascii*) get_ascii; shift; esac # Iterate over the info functions to determine the lengths of the From 8dd5981fbc3b47ebd3108360b0278da9561428c6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 9 Nov 2019 16:44:28 +0000 Subject: [PATCH 04/73] pfetch: remove cursor movement for palette --- pfetch | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pfetch b/pfetch index 80661cd..fc9f428 100755 --- a/pfetch +++ b/pfetch @@ -24,7 +24,11 @@ log() { align=$(printf '%*.s' "$((${#name}-info_length))" "") - out="[3${PF_COL1-4};1m${name}${PF_SEP}${align}[3${PF_COL2-7}m${info}" + # Construct the information string. + out= + out="[3${PF_COL1-4};1m${name}" + out="$out${PF_SEP}${align}" + out="$out[3${PF_COL2-7}m${info}" } get_title() { @@ -781,12 +785,12 @@ get_palette() { # # This allows us to save hardcoding a second set of sequences # for background colors. - palette=" $c1 $c2 $c3 $c4 $c5 $c6 $c7 " + palette="$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " - # Print the palette with a newline before and after. - # The '\033[%sC' moves the text to the right, the - # length of the ascii art. - printf '\n[%sC%s\n' "${ascii_width-1}" "$palette" >&6 + # Print the palette with a new-line before and afterwards. + printf '\n' >&6 + log "$palette + " " " } get_ascii() { From ddc858bfdbe4192783b870303185f171f9916147 Mon Sep 17 00:00:00 2001 From: Nithin Jino Date: Fri, 6 Dec 2019 18:29:08 -0500 Subject: [PATCH 05/73] cpu: added get_cpu --- pfetch | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pfetch b/pfetch index 938fc03..29a2f1f 100755 --- a/pfetch +++ b/pfetch @@ -115,6 +115,37 @@ get_title() { log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 } +get_cpu() { + case $os in + Linux*) + cpu_model=$(grep 'model name' /proc/cpuinfo | uniq | sed 's/.*://') + #cpu_cores=$(grep 'cpu cores' /proc/cpuinfo | uniq | sed 's/.*://' | awk '{$1=$1;print}') + #cpu_threads=$(grep -c processor /proc/cpuinfo) + ryzen="Ryzen" + if test "${cpu_model#*$ryzen}" != "$cpu_model" + then + cpu_freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/bios_limit) + cpu_freq=$((cpu_freq / 10000)) + cpu_freq=$(echo $cpu_freq | sed -e "s/.\{1\}/&./1") + cpu_model=$cpu_model" @ $cpu_freq""Ghz" + fi + ;; + *) + cpu_model="unsupported" + ;; + esac + + cpu_model=$(echo $cpu_model | sed -e s/"Dual-Core Processor"//) + cpu_model=$(echo $cpu_model | sed -e s/"Quad-Core Processor"//) + cpu_model=$(echo $cpu_model | sed -e s/"Six-Core Processor"//) + cpu_model=$(echo $cpu_model | sed -e s/"Eight-Core Processor"//) + cpu_model=$(echo $cpu_model | sed -e s/"(TM)"//) + cpu_model=$(echo $cpu_model | sed -e s/"(tm)"//) + cpu_model=$(echo $cpu_model | sed -e s/"(R)"//) + cpu_model=$(echo $cpu_model | sed -e s/"(r)"//) + log cpu "$cpu_model" >&6 +} + get_os() { # This function is called twice, once to detect the distribution name # for the purposes of picking an ascii art early and secondly to display From 67204770ac05c1937c6ea72f66b57d02b65fe597 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 3 Jan 2020 09:48:20 +0200 Subject: [PATCH 06/73] pfetch: Add support for Endeavour --- pfetch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pfetch b/pfetch index 938fc03..3a90010 100755 --- a/pfetch +++ b/pfetch @@ -1003,6 +1003,17 @@ get_ascii() { EOF ;; + [Ee]ndeavour*) + read_ascii 4 <<-EOF + ${c1}/${c4}\\ + ${c1}/${c4}/ \\${c6}\\ + ${c1}/${c4}/ \\ ${c6}\\ + ${c1}/ ${c4}/ _) ${c6}) + ${c1}/_${c4}/___-- ${c6}__- + ${c6}/____-- + EOF + ;; + [Ff]edora*) read_ascii 4 <<-EOF ${c7} _____ From d410bb2ffb1bc0a9eef8d60fcc2b313fb2f3124d Mon Sep 17 00:00:00 2001 From: Nithin Jino Date: Thu, 23 Jan 2020 13:39:45 -0500 Subject: [PATCH 07/73] cpu: case statement --- pfetch | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pfetch b/pfetch index 29a2f1f..aada80f 100755 --- a/pfetch +++ b/pfetch @@ -119,17 +119,14 @@ get_cpu() { case $os in Linux*) cpu_model=$(grep 'model name' /proc/cpuinfo | uniq | sed 's/.*://') - #cpu_cores=$(grep 'cpu cores' /proc/cpuinfo | uniq | sed 's/.*://' | awk '{$1=$1;print}') - #cpu_threads=$(grep -c processor /proc/cpuinfo) - ryzen="Ryzen" - if test "${cpu_model#*$ryzen}" != "$cpu_model" - then - cpu_freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/bios_limit) - cpu_freq=$((cpu_freq / 10000)) - cpu_freq=$(echo $cpu_freq | sed -e "s/.\{1\}/&./1") - cpu_model=$cpu_model" @ $cpu_freq""Ghz" - fi - ;; + case $cpu_model in + *Ryzen*) + cpu_model="Not implemented" + ;; + *) + ;; + esac + ;; *) cpu_model="unsupported" ;; From 7487a386e7e578f1f702da607dbf8383b9f69217 Mon Sep 17 00:00:00 2001 From: Nithin Jino Date: Thu, 23 Jan 2020 13:40:54 -0500 Subject: [PATCH 08/73] cpu: ryzen --- pfetch | 1 - 1 file changed, 1 deletion(-) diff --git a/pfetch b/pfetch index aada80f..30456a3 100755 --- a/pfetch +++ b/pfetch @@ -121,7 +121,6 @@ get_cpu() { cpu_model=$(grep 'model name' /proc/cpuinfo | uniq | sed 's/.*://') case $cpu_model in *Ryzen*) - cpu_model="Not implemented" ;; *) ;; From a7b0439aebb8943b9ae241e0ec184656d0254a70 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:08:57 +0200 Subject: [PATCH 09/73] pfetch: Added PF_SOURCE. Closes #34 --- README.md | 5 +++++ pfetch | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index df4462a..49b8d5d 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,11 @@ PF_INFO="ascii" # Example: Only Information. PF_INFO="title os host kernel uptime pkgs memory" +# A file to source before running pfetch. +# Default: unset +# Valid: A shell script +PF_SOURCE="" + # Separator between info name and info data. # Default: unset # Valid: string diff --git a/pfetch b/pfetch index 77ee310..2311f16 100755 --- a/pfetch +++ b/pfetch @@ -1296,6 +1296,11 @@ main() { # This gives full control over what it displayed on the screen. exec 6>&1 >/dev/null + # Allow the user to execute their own script and modify or + # extend pfetch's behavior. + # shellcheck source=/dev/null + . "${PF_SOURCE:-/dev/null}" ||: + # Ensure that the 'TMPDIR' is writable as heredocs use it and # fail without the write permission. This was found to be the # case on Android where the temporary directory requires root. From c36607909ba8e18448b739833b338e699b8b810d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:17:23 +0200 Subject: [PATCH 10/73] pfetch: OpenWrt support. Closes #37 --- pfetch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pfetch b/pfetch index 2311f16..8d26f35 100755 --- a/pfetch +++ b/pfetch @@ -1166,6 +1166,19 @@ get_ascii() { EOF ;; + [Oo]pen[Ww]rt*) + read_ascii 1 <<-EOF + ${c1} _______ + | |.-----.-----.-----. + | - || _ | -__| | + |_______|| __|_____|__|__| + ________|__| __ + | | | |.----.| |_ + | | | || _|| _| + |________||__| |____| + EOF + ;; + [Pp]arabola*) read_ascii 5 <<-EOF ${c5} __ __ __ _ From 32743859da5ec395958449a574d8cdb0fb01c042 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:24:34 +0200 Subject: [PATCH 11/73] pfetch: misc --- pfetch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pfetch b/pfetch index 8d26f35..c3dead2 100755 --- a/pfetch +++ b/pfetch @@ -25,10 +25,9 @@ log() { align=$(printf '%*.s' "$((${#name}-info_length))" "") # Construct the information string. - out= out="[3${PF_COL1-4};1m${name}" out="$out${PF_SEP}${align}" - out="$out[3${PF_COL2-7}m${info}" + out="$out[3${PF_COL2-7}m${info}" } get_title() { @@ -1340,13 +1339,11 @@ main() { [ "$TERM" = minix ] || [ "$TERM" = cons25 ] || { # '[?7l': Disable line-wrapping. - # '[?25l': Hide the cursor. - printf '[?7l[?25l' >&6 + printf '[?7l' >&6 # Leave the terminal how we found it on exit or Ctrl+C. # '[?7h': Enable line-wrapping. - # '[?25h': Show the cursor. - trap 'printf [?7h[?25h >&6' EXIT + trap 'printf [?7h >&6' EXIT } # Store the output of 'uname' to avoid calling it multiple times From 8d1b579b39f0ebd5098afe5b5e3e74a03d0f23e5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:26:35 +0200 Subject: [PATCH 12/73] docs: update --- pfetch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pfetch b/pfetch index c3dead2..8f1ea30 100755 --- a/pfetch +++ b/pfetch @@ -1328,9 +1328,7 @@ main() { c7=''; c8='' } - # Avoid text-wrapping from wrecking the program output - # and hide the cursor to hide its moving around during - # the printing process. + # Avoid text-wrapping from wrecking the program output. # # Some terminals don't support these sequences, nor do they # silently conceal them if they're printed resulting in @@ -1338,11 +1336,10 @@ main() { [ "$TERM" = dumb ] || [ "$TERM" = minix ] || [ "$TERM" = cons25 ] || { - # '[?7l': Disable line-wrapping. + # Disable line-wrapping. printf '[?7l' >&6 - # Leave the terminal how we found it on exit or Ctrl+C. - # '[?7h': Enable line-wrapping. + # Enable line-wrapping again on exit. trap 'printf [?7h >&6' EXIT } From 7094147013672179b235ba26431bb9285a6ce3ea Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:33:51 +0200 Subject: [PATCH 13/73] ascii: Fix format --- pfetch | 102 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/pfetch b/pfetch index 8f1ea30..ed756e8 100755 --- a/pfetch +++ b/pfetch @@ -838,54 +838,54 @@ get_ascii() { /${c7}/ ${c4}\\ \\ /${c7}// ${c4}\\ \\ ${c7}// ${c4}\\ \\ - \\ + ${c4}\\ EOF ;; [Aa]ndroid*) read_ascii 2 <<-EOF ${c2} ;, ,; - ';,.-----.,;' - ,' ', - / O O \\ - | | - '-----------------' + ${c2} ';,.-----.,;' + ${c2} ,' ', + ${c2} / O O \\ + ${c2}| | + ${c2}'-----------------' EOF ;; [Aa]rch*) read_ascii 4 <<-EOF ${c6} /\\ - / \\ - /\\ \\ + ${c6} / \\ + ${c6} /\\ \\ ${c4} / \\ - / ,, \\ - / | | -\\ - /_-'' ''-_\\ + ${c4} / ,, \\ + ${c4} / | | -\\ + ${c4} /_-'' ''-_\\ EOF ;; [Aa]rco*) read_ascii 4 <<-EOF ${c4} /\\ - / \\ - / /\\ \\ - / / \\ \\ - / / \\ \\ - / / _____\\ \\ - /_/ \`----.\\_\\ + ${c4} / \\ + ${c4} / /\\ \\ + ${c4} / / \\ \\ + ${c4} / / \\ \\ + ${c4} / / _____\\ \\ + ${c4}/_/ \`----.\\_\\ EOF ;; [Aa]rtix*) read_ascii 6 <<-EOF ${c4} /\\ - / \\ - /\`'.,\\ - / ', - / ,\`\\ - / ,.'\`. \\ - /.,'\` \`'.\\ + ${c4} / \\ + ${c4} /\`'.,\\ + ${c4} / ', + ${c4} / ,\`\\ + ${c4} / ,.'\`. \\ + ${c4}/.,'\` \`'.\\ EOF ;; @@ -904,11 +904,11 @@ get_ascii() { [Dd]ebian*) read_ascii 1 <<-EOF ${c1} _____ - / __ \\ - | / | - | \\___- - -_ - --_ + ${c1} / __ \\ + ${c1}| / | + ${c1}| \\___- + ${c1}-_ + ${c1} --_ EOF ;; @@ -919,19 +919,19 @@ get_ascii() { >--${c1}|${c7}--< (_-'${c1}|${c7}'-_) ${c1}| - | - | + ${c1}| + ${c1}| EOF ;; [Ee]lementary*) read_ascii <<-EOF ${c7} _______ - / ____ \\ - / | / /\\ - |__\\ / / | - \\ /__/ / - \\_______/ + ${c7} / ____ \\ + ${c7}/ | / /\\ + ${c7}|__\\ / / | + ${c7}\\ /__/ / + ${c7}\\_______/ EOF ;; @@ -962,35 +962,35 @@ get_ascii() { [Ff]ree[Bb][Ss][Dd]*) read_ascii 1 <<-EOF ${c1}/\\,-'''''-,/\\ - \\_) (_/ - | | - | | - ; ; - '-_____-' + ${c1}\\_) (_/ + ${c1}| | + ${c1}| | + ${c1}; ; + ${c1}'-_____-' EOF ;; [Gg]entoo*) read_ascii 5 <<-EOF ${c5} _-----_ - ( \\ - \\ 0 \\ + ${c5}( \\ + ${c5}\\ 0 \\ ${c7} \\ ) - / _/ - ( _- - \\____- + ${c7} / _/ + ${c7}( _- + ${c7}\\____- EOF ;; [Gg]uix[Ss][Dd]*|[Gg]uix*) read_ascii 3 <<-EOF ${c3}|.__ __.| - |__ \\ / __| - \\ \\ / / - \\ \\ / / - \\ \\ / / - \\ \\/ / - \\__/ + ${c3}|__ \\ / __| + ${c3}\\ \\ / / + ${c3}\\ \\ / / + ${c3}\\ \\ / / + ${c3}\\ \\/ / + ${c3}\\__/ EOF ;; From 364223cb483e3a9ac488b240b306a4cb53ea99f7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:38:04 +0200 Subject: [PATCH 14/73] ascii: Fix format --- pfetch | 60 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/pfetch b/pfetch index ed756e8..fe56813 100755 --- a/pfetch +++ b/pfetch @@ -997,36 +997,36 @@ get_ascii() { [Hh]aiku*) read_ascii 3 <<-EOF ${c3} ,^, - / \\ - *--_ ; ; _--* - \\ '" "' / - '. .' - .-'" "'-. - '-.__. .__.-' - |_| + ${c3} / \\ + ${c3}*--_ ; ; _--* + ${c3}\\ '" "' / + ${c3}'. .' + ${c3}.-'" "'-. + ${c3}'-.__. .__.-' + ${c3}|_| EOF ;; [Hh]yperbola*) read_ascii <<-EOF ${c7} |\`__.\`/ - \____/ - .--. - / \\ - / ___ \\ - / .\` \`.\\ - /.\` \`.\\ + ${c7} \____/ + ${c7} .--. + ${c7} / \\ + ${c7} / ___ \\ + ${c7}/ .\` \`.\\ + ${c7}/.\` \`.\\ EOF ;; [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ - / \\ - / ${c7}/ ${c3}/ - > ${c7}/ ${c3}/ - \\ ${c7}\\ ${c3}\\ - \\_${c7}\\${c3}_\\ + ${c3} / \\ + ${c3} / ${c7}/ ${c3}/ + ${c3}> ${c7}/ ${c3}/ + ${c3}\\ ${c7}\\ ${c3}\\ + ${c3}\\_${c7}\\${c3}_\\ ${c7} \\ EOF ;; @@ -1034,12 +1034,12 @@ get_ascii() { [Ll]inux*[Mm]int*|[Mm]int) read_ascii 2 <<-EOF ${c2} ___________ - |_ \\ - | ${c7}| _____ ${c2}| - | ${c7}| | | | ${c2}| - | ${c7}| | | | ${c2}| - | ${c7}\\__${c7}___/ ${c2}| - \\_________/ + ${c2}|_ \\ + ${c2}| ${c7}| _____ ${c2}| + ${c2}| ${c7}| | | | ${c2}| + ${c2}| ${c7}| | | | ${c2}| + ${c2}| ${c7}\\__${c7}___/ ${c2}| + ${c2}\\_________/ EOF ;; @@ -1047,10 +1047,10 @@ get_ascii() { [Ll]inux*) read_ascii 4 <<-EOF ${c4} ___ - (${c7}.. ${c4}| - (${c5}<> ${c4}| - / ${c7}__ ${c4}\\ - ( ${c7}/ \\ ${c4}/| + ${c4}(${c7}.. ${c4}| + ${c4}(${c5}<> ${c4}| + ${c4}/ ${c7}__ ${c4}\\ + ${c4}( ${c7}/ \\ ${c4}/| ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4}) ${c5}\/${c4}-____${c5}\/ EOF @@ -1059,9 +1059,9 @@ get_ascii() { [Mm]ac[Oo][Ss]*|[Dd]arwin*) read_ascii 1 <<-EOF ${c1} .:' - _ :'_ + ${c1} _ :'_ ${c2} .'\`_\`-'_\`\`. - :________.-' + ${c2}:________.-' ${c3}:_______: ${c4} :_______\`-; ${c5} \`._.-._.' From 9f55ffb5aaf6265ea2ea10df511675ed43684c6e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 26 Jan 2020 22:44:05 +0200 Subject: [PATCH 15/73] ascii: Fix format --- pfetch | 180 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/pfetch b/pfetch index fe56813..9175356 100755 --- a/pfetch +++ b/pfetch @@ -1071,49 +1071,49 @@ get_ascii() { [Mm]ageia*) read_ascii 2 <<-EOF ${c6} * - * - ** + ${c6} * + ${c6} ** ${c7} /\\__/\\ - / \\ - \\ / - \\____/ + ${c7}/ \\ + ${c7}\\ / + ${c7} \\____/ EOF ;; [Mm]anjaro*) read_ascii 2 <<-EOF ${c2}||||||||| |||| - ||||||||| |||| - |||| |||| - |||| |||| |||| - |||| |||| |||| - |||| |||| |||| - |||| |||| |||| + ${c2}||||||||| |||| + ${c2}|||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| + ${c2}|||| |||| |||| EOF ;; [Mm]inix*) read_ascii 4 <<-EOF ${c4} ,, ,, - ;${c7},${c4} ', ,' ${c7},${c4}; - ; ${c7}',${c4} ',,' ${c7},'${c4} ; - ; ${c7}',${c4} ${c7},'${c4} ; - ; ${c7};, '' ,;${c4} ; - ; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ; - ', ${c7};${c4};; ;;${c7};${c4} ,' - '${c7};${c4}' '${c7};${c4}' + ${c4};${c7},${c4} ', ,' ${c7},${c4}; + ${c4}; ${c7}',${c4} ',,' ${c7},'${c4} ; + ${c4}; ${c7}',${c4} ${c7},'${c4} ; + ${c4}; ${c7};, '' ,;${c4} ; + ${c4}; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ; + ${c4}', ${c7};${c4};; ;;${c7};${c4} ,' + ${c4} '${c7};${c4}' '${c7};${c4}' EOF ;; [Mm][Xx]*) read_ascii <<-EOF ${c7} \\\\ / - \\\\/ - \\\\ - /\\/ \\\\ - / \\ /\\ - / \\/ \\ - /__________\\ + ${c7} \\\\/ + ${c7} \\\\ + ${c7} /\\/ \\\\ + ${c7} / \\ /\\ + ${c7} / \\/ \\ + ${c7}/__________\\ EOF ;; @@ -1124,137 +1124,137 @@ get_ascii() { ${c7} \\\\ ${c3}\`.____ ${c7} \\\\${c3}-______,----\`- ${c7} \\\\ - \\\\ - \\\\ + ${c7} \\\\ + ${c7} \\\\ EOF ;; [Nn]ix[Oo][Ss]*) read_ascii 4 <<-EOF ${c4} \\\\ \\\\ // - ==\\\\__\\\\/ // - // \\\\// - ==// //== - //\\\\___// - // /\\\\ \\\\== - // \\\\ \\\\ + ${c4} ==\\\\__\\\\/ // + ${c4} // \\\\// + ${c4}==// //== + ${c4} //\\\\___// + ${c4}// /\\\\ \\\\== + ${c4} // \\\\ \\\\ EOF ;; [Oo]pen[Bb][Ss][Dd]*) read_ascii 3 <<-EOF ${c3} _____ - \\- -/ - \\_/ \\ - | ${c7}O O${c3} | - |_ < ) 3 ) - / \\ / - /-_____-\\ + ${c3} \\- -/ + ${c3} \\_/ \\ + ${c3} | ${c7}O O${c3} | + ${c3} |_ < ) 3 ) + ${c3} / \\ / + ${c3} /-_____-\\ EOF ;; - [Oo]penSUSE*|[Oo]pen*SUSE*|SUSE*|suse*) + [Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*) read_ascii 2 <<-EOF ${c2} _______ - __| __ \\ - / .\\ \\ - \\__/ | - _______| - \\_______ - __________/ + ${c2}__| __ \\ + ${c2} / .\\ \\ + ${c2} \\__/ | + ${c2} _______| + ${c2} \\_______ + ${c2}__________/ EOF ;; [Oo]pen[Ww]rt*) read_ascii 1 <<-EOF ${c1} _______ - | |.-----.-----.-----. - | - || _ | -__| | - |_______|| __|_____|__|__| - ________|__| __ - | | | |.----.| |_ - | | | || _|| _| - |________||__| |____| + ${c1}| |.-----.-----.-----. + ${c1}| - || _ | -__| | + ${c1}|_______|| __|_____|__|__| + ${c1} ________|__| __ + ${c1}| | | |.----.| |_ + ${c1}| | | || _|| _| + ${c1}|________||__| |____| EOF ;; [Pp]arabola*) read_ascii 5 <<-EOF ${c5} __ __ __ _ - .\`_//_//_/ / \`. - / .\` - / .\` - /.\` - /\` + ${c5}.\`_//_//_/ / \`. + ${c5} / .\` + ${c5} / .\` + ${c5} /.\` + ${c5} /\` EOF ;; [Pp]op!_[Oo][Ss]*) read_ascii 6 <<-EOF ${c6}______ - \\ _ \\ __ - \\ \\ \\ \\ / / - \\ \\_\\ \\ / / - \\ ___\\ /_/ - \\ \\ _ - __\\_\\__(_)_ - (___________) + ${c6}\\ _ \\ __ + ${c6}\\ \\ \\ \\ / / + ${c6}\\ \\_\\ \\ / / + ${c6}\\ ___\\ /_/ + ${c6} \\ \\ _ + ${c6} __\\_\\__(_)_ + ${c6}(___________) EOF ;; [Pp]ure[Oo][Ss]*) read_ascii <<-EOF ${c7} _____________ - | _________ | - | | | | - | | | | - | |_________| | - |_____________| + ${c7}| _________ | + ${c7}| | | | + ${c7}| | | | + ${c7}| |_________| | + ${c7}|_____________| EOF ;; [Ss]lackware*) read_ascii 4 <<-EOF ${c4} ________ - / ______| - | |______ - \\______ \\ - ______| | - | |________/ - |____________ + ${c4} / ______| + ${c4} | |______ + ${c4} \\______ \\ + ${c4} ______| | + ${c4}| |________/ + ${c4}|____________ EOF ;; [Ss]un[Oo][Ss]|[Ss]olaris*) read_ascii 3 <<-EOF ${c3} . .; . - . :; :: ;: . - .;. .. .. .;. - .. .. .. .. - .;, ,;. + ${c3} . :; :: ;: . + ${c3} .;. .. .. .;. + ${c3}.. .. .. .. + ${c3} .;, ,;. EOF ;; [Uu]buntu*) read_ascii 3 <<-EOF ${c3} _ - ---(_) - _/ --- \\ - (_) | | - \\ --- _/ - ---(_) + ${c3} ---(_) + ${c3} _/ --- \\ + ${c3}(_) | | + ${c3} \\ --- _/ + ${c3} ---(_) EOF ;; [Vv]oid*) read_ascii 2 <<-EOF ${c2} _______ - _ \\______ - - | \\ ___ \\ | - | | / \ | | - | | \___/ | | - | \\______ \\_| - -_______\\ + ${c2} _ \\______ - + ${c2}| \\ ___ \\ | + ${c2}| | / \ | | + ${c2}| | \___/ | | + ${c2}| \\______ \\_| + ${c2} -_______\\ EOF ;; From 361a46df6094338509db2a9128f7eb8914448a07 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 7 Mar 2020 14:41:33 +0200 Subject: [PATCH 16/73] docs: update --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 9175356..8a82472 100755 --- a/pfetch +++ b/pfetch @@ -63,7 +63,7 @@ get_os() { Linux*) # Some Linux distributions (which are based on others) # fail to identify as they **do not** change the upstream - # distributions identification packages or files. + # distribution's identification packages or files. # # It is senseless to add a special case in the code for # each and every distribution (which _is_ technically no From f15a8d25dd6a6d7715070d1a015477e660e07881 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 7 Mar 2020 14:48:17 +0200 Subject: [PATCH 17/73] docs: update --- pfetch | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pfetch b/pfetch index 8a82472..0634ba4 100755 --- a/pfetch +++ b/pfetch @@ -855,13 +855,13 @@ get_ascii() { [Aa]rch*) read_ascii 4 <<-EOF - ${c6} /\\ - ${c6} / \\ - ${c6} /\\ \\ - ${c4} / \\ - ${c4} / ,, \\ - ${c4} / | | -\\ - ${c4} /_-'' ''-_\\ + ${c6} /\\ + ${c6} / \\ + ${c6} /\\ \\ + ${c4} / \\ + ${c4} / ,, \\ + ${c4} / | | -\\ + ${c4} /_-'' ''-_\\ EOF ;; @@ -937,12 +937,12 @@ get_ascii() { [Ee]ndeavour*) read_ascii 4 <<-EOF - ${c1}/${c4}\\ - ${c1}/${c4}/ \\${c6}\\ - ${c1}/${c4}/ \\ ${c6}\\ - ${c1}/ ${c4}/ _) ${c6}) - ${c1}/_${c4}/___-- ${c6}__- - ${c6}/____-- + ${c1}/${c4}\\ + ${c1}/${c4}/ \\${c6}\\ + ${c1}/${c4}/ \\ ${c6}\\ + ${c1}/ ${c4}/ _) ${c6}) + ${c1}/_${c4}/___-- ${c6}__- + ${c6}/____-- EOF ;; From 25324687b537f7ca84d690b051b62cb2c0d62f62 Mon Sep 17 00:00:00 2001 From: Daniel Thau Date: Fri, 6 Mar 2020 17:13:43 -0500 Subject: [PATCH 18/73] pfetch: Add support for Bedrock Bedrock mimics other distros. Part of doing so involves having distro identifiers such as /etc/os-release look like those from other distros. It must thus be special cased to be detected properly. Bedrock typically includes /bedrock/cross/* entries in its $PATH. However, they may be dropped as a hint to Bedrock-aware software that they should act as though they were not Bedrock aware. The $PATH check is thus used to have pfetch conditionally disable the Bedrock special casing even on Bedrock systems. pfetch package count detection fails to consider repeated instances of a given package manager. Correcting this for the Bedrock specific concern is purposefully eschewed for the sake of simplicity. It may be revisited later once Bedrock's Package Manager Manager ("pmm") feature stabilizes. --- pfetch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pfetch b/pfetch index 9175356..a1a380e 100755 --- a/pfetch +++ b/pfetch @@ -113,6 +113,9 @@ get_os() { # don't follow any os-release/lsb standards whatsoever. command -v crux && distro=$(crux) command -v guix && distro='Guix System' + case $PATH in + */bedrock/cross/*) distro='Bedrock Linux' + esac # Check to see if Linux is running in Windows 10 under # WSL1 (Windows subsystem for Linux [version 1]) and @@ -889,6 +892,15 @@ get_ascii() { EOF ;; + [Bb]edrock*) + read_ascii 4 <<-EOF + ${c7}__ + ${c7}\\ \\___ + ${c7} \\ _ \\ + ${c7} \\___/ + EOF + ;; + [Cc]ent[Oo][Ss]*) read_ascii 5 <<-EOF ${c2} ____${c3}^${c5}____ From f5b527d852acb84233f7e46d52870773ab789dc2 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 7 Mar 2020 17:52:25 +0200 Subject: [PATCH 19/73] docs: update --- pfetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pfetch b/pfetch index 568aa58..35560b6 100755 --- a/pfetch +++ b/pfetch @@ -113,6 +113,10 @@ get_os() { # don't follow any os-release/lsb standards whatsoever. command -v crux && distro=$(crux) command -v guix && distro='Guix System' + + # Check to see if we're running Bedrock Linux which is + # very unique. This simply checks to see if the user's + # PATH contais a Bedrock specific value. case $PATH in */bedrock/cross/*) distro='Bedrock Linux' esac From c1cecae824dbb7c045d218a047d47d50b767fa50 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 08:29:35 +0200 Subject: [PATCH 20/73] pfetch: Minix host information --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 35560b6..9baf21f 100755 --- a/pfetch +++ b/pfetch @@ -249,7 +249,7 @@ get_host() { machdep.dmi.system-product) ;; - *BSD*) + *BSD*|Minix) host=$(sysctl -n hw.vendor hw.product) ;; esac From 4cfef9c1e4f3d8df75f629c2ee6292a5a56b5944 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 12:27:53 +0200 Subject: [PATCH 21/73] pfetch: Initial IRIX support. --- pfetch | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 9baf21f..b8e2fd7 100755 --- a/pfetch +++ b/pfetch @@ -218,7 +218,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) ;; + *BSD*|Haiku|Minix|IRIX*) ;; *) # '$kernel' is the cached output of 'uname -r'. @@ -336,6 +336,10 @@ get_uptime() { $(kstat -p unix:0:system_misc:snaptime) EOF ;; + + IRIX*) + # TODO + ;; esac # Convert the uptime from seconds into days, hours and minutes. @@ -447,6 +451,11 @@ get_pkgs() { has pkginfo && pkginfo -i has pkg && pkg list ;; + + IRIX*) + # TODO: result - 3. + versions -b + ;; esac | wc -l ` @@ -630,6 +639,10 @@ get_memory() { mem_free=$((pages_free * hw_pagesize / 1024 / 1024)) mem_used=$((mem_full - mem_free)) ;; + + IRIX*) + # TODO + ;; esac log memory "${mem_used:-?}M / ${mem_full:-?}M" @@ -1035,6 +1048,13 @@ get_ascii() { EOF ;; + [Ii]rix*) + read_ascii 4 <<-EOF + TODO + EOF + ;; + + [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ From be111026b19e09ece03a964ccff9c1e67dadf30a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 12:30:11 +0200 Subject: [PATCH 22/73] ascii: Remove blank line --- pfetch | 1 - 1 file changed, 1 deletion(-) diff --git a/pfetch b/pfetch index b8e2fd7..41f07b6 100755 --- a/pfetch +++ b/pfetch @@ -1054,7 +1054,6 @@ get_ascii() { EOF ;; - [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ From f82f5e9d2d6b6ca22587dcf643ef55da73fd74d7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 13:59:58 +0200 Subject: [PATCH 23/73] pfetch: Remove non-posix dot --- pfetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 9baf21f..8d44c36 100755 --- a/pfetch +++ b/pfetch @@ -22,7 +22,7 @@ log() { info=$* } - align=$(printf '%*.s' "$((${#name}-info_length))" "") + align=$(printf '%*s' "$((${#name}-info_length))" "") # Construct the information string. out="[3${PF_COL1-4};1m${name}" @@ -1401,7 +1401,7 @@ main() { while IFS= read -r line || [ "$1" ]; do "get_$1" shift "$(($# ? 1 : 0))" - printf '%*.s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 + printf '%*s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 out= done <<-EOF $ascii From 3bb449700c438656477cb5d4c897da3f1a8c53ed Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 14:50:06 +0200 Subject: [PATCH 24/73] pfetch: posix --- pfetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pfetch b/pfetch index 8d44c36..0140bc8 100755 --- a/pfetch +++ b/pfetch @@ -22,11 +22,9 @@ log() { info=$* } - align=$(printf '%*s' "$((${#name}-info_length))" "") - # Construct the information string. out="[3${PF_COL1-4};1m${name}" - out="$out${PF_SEP}${align}" + out="$out${PF_SEP}[$((${#name}-info_length))D" out="$out[3${PF_COL2-7}m${info}" } @@ -1401,7 +1399,7 @@ main() { while IFS= read -r line || [ "$1" ]; do "get_$1" shift "$(($# ? 1 : 0))" - printf '%*s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 + printf '\033[%sC%s\r%s\n' "$ascii_width" "$out" "$line" >&6 out= done <<-EOF $ascii From 9fc34b000093d32d552bc1bde4fca6074bcd9427 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 15:18:50 +0200 Subject: [PATCH 25/73] pfetch: Revert prior change --- pfetch | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 0140bc8..8d44c36 100755 --- a/pfetch +++ b/pfetch @@ -22,9 +22,11 @@ log() { info=$* } + align=$(printf '%*s' "$((${#name}-info_length))" "") + # Construct the information string. out="[3${PF_COL1-4};1m${name}" - out="$out${PF_SEP}[$((${#name}-info_length))D" + out="$out${PF_SEP}${align}" out="$out[3${PF_COL2-7}m${info}" } @@ -1399,7 +1401,7 @@ main() { while IFS= read -r line || [ "$1" ]; do "get_$1" shift "$(($# ? 1 : 0))" - printf '\033[%sC%s\r%s\n' "$ascii_width" "$out" "$line" >&6 + printf '%*s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 out= done <<-EOF $ascii From 271458be6eb4e325f263f430bc9d0c544c3a771d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 15:24:49 +0200 Subject: [PATCH 26/73] pfetch: Fixed posix change --- pfetch | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pfetch b/pfetch index 8d44c36..9e119eb 100755 --- a/pfetch +++ b/pfetch @@ -22,11 +22,9 @@ log() { info=$* } - align=$(printf '%*s' "$((${#name}-info_length))" "") - # Construct the information string. out="[3${PF_COL1-4};1m${name}" - out="$out${PF_SEP}${align}" + out="$out${PF_SEP}[$((info_length-${#name}))C" out="$out[3${PF_COL2-7}m${info}" } @@ -1401,7 +1399,7 @@ main() { while IFS= read -r line || [ "$1" ]; do "get_$1" shift "$(($# ? 1 : 0))" - printf '%*s%s\r%s\n' "$ascii_width" "" "$out" "$line" >&6 + printf '\033[%sC%s\r%s\n' "$ascii_width" "$out" "$line" >&6 out= done <<-EOF $ascii From b2aac93208b8a93edaff96f26b8dc6c4bfb0af4d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 22:48:23 +0200 Subject: [PATCH 27/73] irix: Memory usage --- pfetch | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 41f07b6..69b08b7 100755 --- a/pfetch +++ b/pfetch @@ -641,7 +641,24 @@ get_memory() { ;; IRIX*) - # TODO + # Read the memory information from the 'top' command. Parse + # and split each line until we reach the line starting with + # "Memory". + # + # Example output: Memory: 160M max, 147M avail, ..... + while IFS=' :' read -r label mem_full _ mem_free _; do + case $label in + Memory) + mem_full=${mem_full%M} + mem_free=${mem_free%M} + break + ;; + esac + done <<-EOF + $(top -n) + EOF + + mem_used=$((mem_full - mem_free)) ;; esac From 39f767e45bc8e81609a67157bdb46c5819be345f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 22:57:10 +0200 Subject: [PATCH 28/73] irix: Uptime support. --- pfetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 69b08b7..c7dbd09 100755 --- a/pfetch +++ b/pfetch @@ -338,7 +338,22 @@ get_uptime() { ;; IRIX*) - # TODO + # Grab the uptime in a pretty format. Usually, + # 00:00:00 from the 'ps' command. + t=$(LC_ALL=POSIX ps -o etime= -p 1) + + # Split the pretty output into days or hours + # based on the uptime. + case $t in + *-*) d=${t%%-*} t=${t#*-} ;; + *:*:*) h=${t%%:*} t=${t#*:} ;; + esac + + h=${h#0} t=${t#0} + + # Convert the split pretty fields back into + # seconds so we may re-convert them to our format. + s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:})) ;; esac From e2068c61d5f0d3408745bc322847413dac736fd0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:07:42 +0200 Subject: [PATCH 29/73] IRIX: Packages support --- pfetch | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pfetch b/pfetch index c7dbd09..d32a9b2 100755 --- a/pfetch +++ b/pfetch @@ -218,7 +218,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix|IRIX*) ;; + *BSD*|Haiku|Minix|IRIX) ;; *) # '$kernel' is the cached output of 'uname -r'. @@ -337,7 +337,7 @@ get_uptime() { EOF ;; - IRIX*) + IRIX) # Grab the uptime in a pretty format. Usually, # 00:00:00 from the 'ps' command. t=$(LC_ALL=POSIX ps -o etime= -p 1) @@ -467,13 +467,18 @@ get_pkgs() { has pkg && pkg list ;; - IRIX*) - # TODO: result - 3. + IRIX) versions -b ;; esac | wc -l ` + case $os in + # IRIX's package manager adds 3 lines of extra + # output which we must account for here. + IRIX) packages=$((packages - 3)) ;; + esac + [ "$packages" -gt 1 ] && log pkgs "$packages" } @@ -655,7 +660,7 @@ get_memory() { mem_used=$((mem_full - mem_free)) ;; - IRIX*) + IRIX) # Read the memory information from the 'top' command. Parse # and split each line until we reach the line starting with # "Memory". From 177d77c33523380a9ab5f7d920170c9488b6034b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:25:30 +0200 Subject: [PATCH 30/73] irix: Fix support --- pfetch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index d32a9b2..2753301 100755 --- a/pfetch +++ b/pfetch @@ -1085,9 +1085,15 @@ get_ascii() { EOF ;; - [Ii]rix*) + [Ii][Rr][Ii][Xx]*) read_ascii 4 <<-EOF TODO + TODO + TODO + TODO + TODO + TODO + TODO EOF ;; From 6558b34254d9eb6b974e96e410555435b13e52f1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:41:13 +0200 Subject: [PATCH 31/73] irix: kernel information --- pfetch | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 4058c39..2c8ee97 100755 --- a/pfetch +++ b/pfetch @@ -25,7 +25,7 @@ log() { # Construct the information string. out="[3${PF_COL1-4};1m${name}" out="$out${PF_SEP}[$((info_length-${#name}))C" - out="$out[3${PF_COL2-7}m${info}" + out="$out[3${PF_COL2-7}m${info:-?}" } get_title() { @@ -216,7 +216,12 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix|IRIX) ;; + *BSD*|Haiku|Minix) ;; + + IRIX) + kernel=$(uname -vR) + kernel=${kernel#* } + ;; *) # '$kernel' is the cached output of 'uname -r'. From 577e8483a787434f90f2843081eda706828174ea Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 10 Mar 2020 00:06:06 +0200 Subject: [PATCH 32/73] irix: ASCII --- pfetch | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pfetch b/pfetch index 2c8ee97..5c1565a 100755 --- a/pfetch +++ b/pfetch @@ -25,7 +25,7 @@ log() { # Construct the information string. out="[3${PF_COL1-4};1m${name}" out="$out${PF_SEP}[$((info_length-${#name}))C" - out="$out[3${PF_COL2-7}m${info:-?}" + out="$out[3${PF_COL2-7}m$info" } get_title() { @@ -216,7 +216,9 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) ;; + *BSD*|Haiku|Minix) + log kernel "?" + ;; IRIX) kernel=$(uname -vR) @@ -1089,14 +1091,14 @@ get_ascii() { ;; [Ii][Rr][Ii][Xx]*) - read_ascii 4 <<-EOF - TODO - TODO - TODO - TODO - TODO - TODO - TODO + read_ascii 1 <<-EOF + ${c1} __ + ${c1} \\ \\ __ + ${c1} \\ \\ / / + ${c1} \\ v / + ${c1} / . \\ + ${c1} /_/ \\ \\ + ${c1} \\_\\ EOF ;; From a8a3e1f2fe54b7b9e662c612ed7975fa73f5fdf7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 10 Mar 2020 00:08:47 +0200 Subject: [PATCH 33/73] docs: update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 49b8d5d..88ee53b 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ picture"! - **MacOS** - **Minix** - **Solaris** +- **IRIX** ## Configuration From c0d0d65aa04ca1dea17e4287d89d1e5eaa391ea8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 10 Mar 2020 12:26:29 +0200 Subject: [PATCH 34/73] pfetch: Fix blank lines --- pfetch | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 5c1565a..4e67358 100755 --- a/pfetch +++ b/pfetch @@ -1466,8 +1466,14 @@ main() { info_length=$((info_length + 1)) while IFS= read -r line || [ "$1" ]; do - "get_$1" - shift "$(($# ? 1 : 0))" + # Iterate over the info skipping any lines + # which are blank. + for info; do + "get_$1" + shift "$(($# ? 1 : 0))" + [ "$out" ] && break + done + printf '\033[%sC%s\r%s\n' "$ascii_width" "$out" "$line" >&6 out= done <<-EOF From aa22d4e32daadb400f5a5e1e41b8cab28f39a554 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 10 Mar 2020 12:27:37 +0200 Subject: [PATCH 35/73] pfetch: bold ascii --- pfetch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 4e67358..af861ec 100755 --- a/pfetch +++ b/pfetch @@ -1474,10 +1474,11 @@ main() { [ "$out" ] && break done - printf '\033[%sC%s\r%s\n' "$ascii_width" "$out" "$line" >&6 + printf '\033[%sC%s\033[m\r\033[1m%s\033[m\n' \ + "$ascii_width" "$out" "$line" >&6 out= done <<-EOF - $ascii + $ascii EOF } } From 2ef3584f5b88ba69d3846f3e638a808e7575c338 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 11 Mar 2020 22:25:02 +0200 Subject: [PATCH 36/73] various: Once again hide kernel. Related to #46 --- pfetch | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pfetch b/pfetch index af861ec..c7174b3 100755 --- a/pfetch +++ b/pfetch @@ -216,9 +216,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) - log kernel "?" - ;; + *BSD*|Haiku|Minix) ;; IRIX) kernel=$(uname -vR) From 675814f33e5581265eb5931dd30ae984c587c734 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 11 Mar 2020 22:39:16 +0200 Subject: [PATCH 37/73] pfetch: Revert to larger but more reliable print method. Closes #46 --- pfetch | 164 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 119 insertions(+), 45 deletions(-) diff --git a/pfetch b/pfetch index c7174b3..20cca5e 100755 --- a/pfetch +++ b/pfetch @@ -3,6 +3,59 @@ # pfetch - Simple POSIX sh fetch script. log() { + # The 'log()' function handles the printing of information. + # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info + # happen independently of each other. + # + # The size of the ascii art is stored and the ascii is printed first. + # Once the ascii is printed, the cursor is located right below the art + # (See marker $[1]). + # + # Using the stored ascii size, the cursor is then moved to marker $[2]. + # This is simply a cursor up escape sequence using the "height" of the + # ascii art. + # + # 'log()' then moves the cursor to the right the "width" of the ascii art + # with an additional amount of padding to add a gap between the art and + # the information (See marker $[3]). + # + # When 'log()' has executed, the cursor is then located at marker $[4]. + # When 'log()' is run a second time, the next line of information is + # printed, moving the cursor to marker $[5]. + # + # Markers $[4] and $[5] repeat all the way down through the ascii art + # until there is no more information left to print. + # + # Every time 'log()' is called the script keeps track of how many lines + # were printed. When printing is complete the cursor is then manually + # placed below the information and the art according to the "heights" + # of both. + # + # The math is simple: move cursor down $((ascii_height - info_height)). + # If the aim is to move the cursor from marker $[5] to marker $[6], + # plus the ascii height is 8 while the info height is 2 it'd be a move + # of 6 lines downwards. + # + # However, if the information printed is "taller" (takes up more lines) + # than the ascii art, the cursor isn't moved at all! + # + # Once the cursor is at marker $[6], the script exits. This is the gist + # of how this "dynamic" printing and layout works. + # + # This method allows ascii art to be stored without markers for info + # and it allows for easy swapping of info order and amount. + # + # $[2] ___ $[3] goldie@KISS + # $[4](.· | $[5] os KISS Linux + # (<> | + # / __ \ + # ( / \ /| + # _/\ __)/_) + # \/-____\/ + # $[1] + # + # $[6] /home/goldie $ + # End here if no data was found. [ "$2" ] || return @@ -22,10 +75,27 @@ log() { info=$* } - # Construct the information string. - out="[3${PF_COL1-4};1m${name}" - out="$out${PF_SEP}[$((info_length-${#name}))C" - out="$out[3${PF_COL2-7}m$info" + # Move the cursor to the right, the width of the ascii art with an + # additional gap for text spacing. + printf '[%sC' "${ascii_width--1}" + + # Print the info name and color the text. + printf '[3%s;1m%s' "${PF_COL1-4}" "$name" + + # Print the info name and info data separator. + printf %s "$PF_SEP" + + # Move the cursor backward the length of the *current* info name and + # then move it forwards the length of the *longest* info name. This + # aligns each info data line. + printf '[%sD[%sC' "${#name}" "${PF_ALIGN-$info_length}" + + # Print the info data, color it and strip all leading whitespace + # from the string. + printf '[3%sm%s\n' "${PF_COL2-7}" "$info" + + # Keep track of the number of times 'log()' has been run. + info_height=$((${info_height:-0} + 1)) } get_title() { @@ -42,7 +112,7 @@ get_title() { # shellcheck disable=SC2039 hostname=${HOSTNAME:-${hostname:-$(hostname)}} - log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " + log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 } get_os() { @@ -53,7 +123,7 @@ get_os() { # On first run, this function displays _nothing_, only on the second # invocation is 'log()' called. [ "$distro" ] && { - log os "$distro" + log os "$distro" >&6 return } @@ -216,18 +286,13 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) ;; - - IRIX) - kernel=$(uname -vR) - kernel=${kernel#* } + *BSD*|Haiku|Minix) + return ;; + esac - *) - # '$kernel' is the cached output of 'uname -r'. - log kernel "$kernel" - ;; - esac + # '$kernel' is the cached output of 'uname -r'. + log kernel "$kernel" >&6 } get_host() { @@ -296,7 +361,7 @@ get_host() { done # '$arch' is the cached output from 'uname -m'. - log host "${host:-$arch}" + log host "${host:-$arch}" >&6 } get_uptime() { @@ -370,7 +435,7 @@ get_uptime() { [ "$h" = 0 ] || uptime="${uptime}${h}h " [ "$m" = 0 ] || uptime="${uptime}${m}m " - log uptime "${uptime:-0m}" + log uptime "${uptime:-0m}" >&6 } get_pkgs() { @@ -482,7 +547,7 @@ get_pkgs() { IRIX) packages=$((packages - 3)) ;; esac - [ "$packages" -gt 1 ] && log pkgs "$packages" + [ "$packages" -gt 1 ] && log pkgs "$packages" >&6 } get_memory() { @@ -685,7 +750,7 @@ get_memory() { ;; esac - log memory "${mem_used:-?}M / ${mem_full:-?}M" + log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 } get_wm() { @@ -814,7 +879,7 @@ get_wm() { ;; esac - log wm "$wm" + log wm "$wm" >&6 } @@ -825,18 +890,18 @@ get_de() { # # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, # display the value of '$DESKTOP_SESSION'. - log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" + log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6 } get_shell() { # Display the basename of the '$SHELL' environment variable. - log shell "${SHELL##*/}" + log shell "${SHELL##*/}" >&6 } get_editor() { # Display the value of '$VISUAL', if it's empty, display the # value of '$EDITOR'. - log editor "${VISUAL:-$EDITOR}" + log editor "${VISUAL:-$EDITOR}" >&6 } get_palette() { @@ -850,8 +915,8 @@ get_palette() { # Print the palette with a new-line before and afterwards. printf '\n' >&6 - log "$palette - " " " + log "$palette + " " " >&6 } get_ascii() { @@ -1363,6 +1428,8 @@ get_ascii() { # information. The 'sed' is used to strip 'm' color codes from # the ascii art so they don't affect the width variable. while read -r line; do + ascii_height=$((${ascii_height:-0} + 1)) + # This was a ternary operation but they aren't supported in # Minix's shell. [ "${#line}" -gt "${ascii_width:-0}" ] && @@ -1378,6 +1445,13 @@ get_ascii() { # Add a gap between the ascii art and the information. ascii_width=$((ascii_width + 4)) + + # Print the ascii art and position the cursor back where we + # started prior to printing it. + # '[1m': Print the ascii in bold. + # '[m': Clear bold. + # '[%sA': Move the cursor up '$ascii_height' amount of lines. + printf '%s[%sA' "$ascii" "$ascii_height" >&6 } main() { @@ -1444,10 +1518,6 @@ main() { set -f set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} - # Grab the ascii art if the user has enabled it. This simply - # populates the '$ascii' variable. - case $@ in *ascii*) get_ascii; shift; esac - # Iterate over the info functions to determine the lengths of the # "info names" for output alignment. The option names and subtitles # match 1:1 so this is thankfully simple. @@ -1463,22 +1533,26 @@ main() { # Add an additional space of length to act as a gap. info_length=$((info_length + 1)) - while IFS= read -r line || [ "$1" ]; do - # Iterate over the info skipping any lines - # which are blank. - for info; do - "get_$1" - shift "$(($# ? 1 : 0))" - [ "$out" ] && break - done - - printf '\033[%sC%s\033[m\r\033[1m%s\033[m\n' \ - "$ascii_width" "$out" "$line" >&6 - out= - done <<-EOF - $ascii - EOF + # Iterate over the above list and run any existing "get_" functions. + for info; do "get_$info"; done } + + # Position the cursor below both the ascii art and information lines + # according to the height of both. If the information exceeds the ascii + # art in height, don't touch the cursor (0/unset), else move it down + # N lines. + # + # This was a ternary operation but they aren't supported in Minix's shell. + [ "${info_height:-0}" -lt "${ascii_height:-0}" ] && + cursor_pos=$((ascii_height - info_height)) + + # Print '$cursor_pos' amount of newlines to correctly position the + # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only + # typically available (by default) on GNU based systems! + while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do + printf '\n' + i=$((i + 1)) + done >&6 } main "$@" From 7503fcc37bd78f1a5080ea2b46f79239d8bd69fb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 00:42:45 +0200 Subject: [PATCH 38/73] pfetch: Add --version. Closes #47 --- pfetch | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pfetch b/pfetch index 20cca5e..94e5eb9 100755 --- a/pfetch +++ b/pfetch @@ -1455,6 +1455,11 @@ get_ascii() { } main() { + [ "$1" = --version ] && { + printf 'pfetch 0.7.0\n' + exit + } + # Hide 'stderr' unless the first argument is '-v'. This saves # polluting the script with '2>/dev/null'. [ "$1" = -v ] || exec 2>/dev/null From 6ce6b1a0f7e438faf4a8578fde201630dea8926a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 12:35:22 +0200 Subject: [PATCH 39/73] openbsd: Show current --- pfetch | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pfetch b/pfetch index 94e5eb9..edfda88 100755 --- a/pfetch +++ b/pfetch @@ -274,6 +274,16 @@ get_os() { IFS='(' read -r distro _ < /etc/release ;; + OpenBSD) + # Show the OpenBSD version type (current if present). + # kern.version=OpenBSD 6.6-current (GENERIC.MP) ... + IFS=' =' read -r _ distro openbsd_ver _ <<-EOF + $(sysctl kern.version) + EOF + + distro="$distro $openbsd_ver" + ;; + *) # Catch all to ensure '$distro' is never blank. # This also handles the BSDs. From c8aca296c1dfcb38846525f08eb6668a3daf7b1c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 12:36:13 +0200 Subject: [PATCH 40/73] openbsd: Show host correctly --- pfetch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index edfda88..04d27a0 100755 --- a/pfetch +++ b/pfetch @@ -274,7 +274,7 @@ get_os() { IFS='(' read -r distro _ < /etc/release ;; - OpenBSD) + OpenBSD*) # Show the OpenBSD version type (current if present). # kern.version=OpenBSD 6.6-current (GENERIC.MP) ... IFS=' =' read -r _ distro openbsd_ver _ <<-EOF @@ -327,6 +327,10 @@ get_host() { machdep.dmi.system-product) ;; + OpenBSD*) + host=$(sysctl -n hw.version) + ;; + *BSD*|Minix) host=$(sysctl -n hw.vendor hw.product) ;; From 44aaae774fe99172fe28510c37542d70ea59d952 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 21:47:39 +0200 Subject: [PATCH 41/73] wm: Fix issues. Related to #48 --- pfetch | 72 +++++++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/pfetch b/pfetch index 04d27a0..4b5af36 100755 --- a/pfetch +++ b/pfetch @@ -845,51 +845,35 @@ get_wm() { # To extract the name, everything before '_NET_WM_NAME = \"' # is removed and everything after the next '"' is removed. wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t) - - # Handle cases of a window manager _not_ populating the - # '_NET_WM_NAME' atom. Display nothing in this case. - case $wm in - *'_NET_WM_NAME = '*) - wm=${wm##*_NET_WM_NAME = \"} - wm=${wm%%\"*} - ;; - - *) - # Fallback to checking the process list - # for the select few window managers which - # don't set '_NET_WM_NAME'. - # - # TODO: This is currently limited to 'grep' - # implementations providing the '-o' - # flag. This needs to be replaced with - # a command which searches for a list - # of strings and returns _only_ the - # first match's contents (also ensuring - # the search itself isn't matched). - # - # A generic parser isn't possible as - # the output of 'ps' is _not_ the same - # between implementations and across - # operating systems. - # - # The simple search method above works - # regardless of 'ps' implementation. - # - # Disable the shellcheck warning about using - # 'pgrep' instead of 'ps | grep' as 'pgrep' - # is not always available. - # shellcheck disable=2009 - wm=$(ps x | grep -o \ - -e '[c]atwm' \ - -e '[f]vwm' \ - -e '[d]wm' \ - -e '[2]bwm' \ - -e '[m]onsterwm' \ - -e '[w]maker' \ - -e '[s]owm') - ;; - esac } + + # Handle cases of a window manager _not_ populating the + # '_NET_WM_NAME' atom. Display nothing in this case. + case $wm in + *'_NET_WM_NAME = '*) + wm=${wm##*_NET_WM_NAME = \"} + wm=${wm%%\"*} + ;; + + *) + # Fallback to checking the process list + # for the select few window managers which + # don't set '_NET_WM_NAME'. + while read -r ps_line; do + case $ps_line in + *catwm*) wm=catwm ;; + *fvwm*) wm=fvwm ;; + *dwm*) wm=dwm ;; + *2bwm*) wm=2bwm ;; + *monsterwm*) wm=monsterwm ;; + *wmaker*) wm='Window Maker' ;; + *sowm*) wm=sowm ;; + esac + done <<-EOF + $(ps x) + EOF + ;; + esac ;; esac From 3a33033120cfd8a30af6b1d753a6da935ee75b3f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 22:01:30 +0200 Subject: [PATCH 42/73] pfetch: Fix potential align issue --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 4b5af36..9ca2b75 100755 --- a/pfetch +++ b/pfetch @@ -88,7 +88,7 @@ log() { # Move the cursor backward the length of the *current* info name and # then move it forwards the length of the *longest* info name. This # aligns each info data line. - printf '[%sD[%sC' "${#name}" "${PF_ALIGN-$info_length}" + printf '[%sD[%sC' "${#name}" "${PF_ALIGN:-$info_length}" # Print the info data, color it and strip all leading whitespace # from the string. From e30fc1075c679d3ab9e7db7c41beeed25dbe0784 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 12 Mar 2020 22:02:40 +0200 Subject: [PATCH 43/73] pfetch: Use -- with set --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 9ca2b75..dae4303 100755 --- a/pfetch +++ b/pfetch @@ -1519,7 +1519,7 @@ main() { # Disable globbing and set the positional parameters to the # contents of 'PF_INFO'. set -f - set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} + set +f -- ${PF_INFO-ascii title os host kernel uptime pkgs memory} # Iterate over the info functions to determine the lengths of the # "info names" for output alignment. The option names and subtitles From eec8c7ce5f6db1285197fcadb0dbaacab179fcf3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 21 Mar 2020 10:27:18 +0200 Subject: [PATCH 44/73] pfetch: Added Makefile. Closes #49 --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cd750f2 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +PREFIX ?= /usr + +all: + @echo RUN \'make install\' to install pfetch + +install: + @install -Dm 755 pfetch $(DESTDIR)$(PREFIX)/bin/pfetch + +uninstall: + @rm -f $(DESTDIR)$(PREFIX)/bin/pfetch From 49b1a8772620a923ba43e4803583a389bd9a34fb Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> Date: Mon, 30 Mar 2020 01:18:50 +0200 Subject: [PATCH 45/73] Correct nix package path --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index dae4303..ebb2831 100755 --- a/pfetch +++ b/pfetch @@ -497,7 +497,7 @@ get_pkgs() { # 'nix' requires two commands. has nix-store && { nix-store -q --requisites /run/current-system/sw - nix-store -q --requisites ~.nix-profile + nix-store -q --requisites ~/.nix-profile } ;; From f88683c83e4b5e4f5890b36bbb454b89b30fc010 Mon Sep 17 00:00:00 2001 From: Morgaux <34286986+Morgaux@users.noreply.github.com> Date: Fri, 17 Apr 2020 04:50:35 +1200 Subject: [PATCH 46/73] Spelling changes --- pfetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index ebb2831..2b13b9b 100755 --- a/pfetch +++ b/pfetch @@ -184,7 +184,7 @@ get_os() { # Check to see if we're running Bedrock Linux which is # very unique. This simply checks to see if the user's - # PATH contais a Bedrock specific value. + # PATH contains a Bedrock specific value. case $PATH in */bedrock/cross/*) distro='Bedrock Linux' esac @@ -883,7 +883,7 @@ get_wm() { get_de() { # This only supports Xorg related desktop environments though - # this is fine as knowing the desktop envrionment on Windows, + # this is fine as knowing the desktop environment on Windows, # macOS etc is useless (they'll always report the same value). # # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, From 274b61b1e60188f96553e268cffb0fc7ae574d52 Mon Sep 17 00:00:00 2001 From: Hunter Peavey Date: Sat, 25 Apr 2020 20:48:10 -0700 Subject: [PATCH 47/73] Add GNU ascii --- pfetch | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pfetch b/pfetch index 2b13b9b..75af701 100755 --- a/pfetch +++ b/pfetch @@ -1114,6 +1114,27 @@ get_ascii() { EOF ;; + [Gg][Nn][Uu]*) + read_ascii 3 <<-EOF + ${c2} _-\`\`\`-, ,-\`\`\`-_ + ${c2} .' -_| |_- '. + ${c2} /.' / \\ '.\\ + ${c2},/ / \\ \\, + ${c2}:: ::_._ _._:: :: + ${c2}:: _/_._\`:'_._\\_ :: + ${c2} \\:._/ ,\` \\\\_.:/ + ${c2} ;/, |-. \\-. \\ + ${c2} ,-'; '.@) \\ @) | + ${c2} ,'/' ..- .\\,-.| + ${c2} /'/' \\(( \\ \` ./ ) + ${c2} '/'' \\_,-----' + ${c2} '/'' ;:/ + ${c2} ''/' ''/ + ${c2} '/'''/'' + ${c2} \`; + EOF + ;; + [Gg]uix[Ss][Dd]*|[Gg]uix*) read_ascii 3 <<-EOF ${c3}|.__ __.| From fdedf2425afa2083b99a470033ca9f2594e57c85 Mon Sep 17 00:00:00 2001 From: Hunter Peavey Date: Sun, 26 Apr 2020 14:02:24 -0700 Subject: [PATCH 48/73] Make GNU ASCII smaller --- pfetch | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/pfetch b/pfetch index 75af701..209100c 100755 --- a/pfetch +++ b/pfetch @@ -1116,22 +1116,17 @@ get_ascii() { [Gg][Nn][Uu]*) read_ascii 3 <<-EOF - ${c2} _-\`\`\`-, ,-\`\`\`-_ - ${c2} .' -_| |_- '. - ${c2} /.' / \\ '.\\ - ${c2},/ / \\ \\, - ${c2}:: ::_._ _._:: :: - ${c2}:: _/_._\`:'_._\\_ :: - ${c2} \\:._/ ,\` \\\\_.:/ - ${c2} ;/, |-. \\-. \\ - ${c2} ,-'; '.@) \\ @) | - ${c2} ,'/' ..- .\\,-.| - ${c2} /'/' \\(( \\ \` ./ ) - ${c2} '/'' \\_,-----' - ${c2} '/'' ;:/ - ${c2} ''/' ''/ - ${c2} '/'''/'' - ${c2} \`; + ${c2} _-\`\`-, ,-\`\`-_ + ${c2} .' _-_| |_-_ '. + ${c2}./ /_._ _._\\ \\. + ${c2}: _/_._\`:'_._\\_ : + ${c2}\\:._/ ,\` \\ \\ \\_.:/ + ${c2} ,-';'.@) \\ @) | + ${c2} ,'/' ..- .\\,-.| + ${c2} /'/' \\(( \\\` ./ ) + ${c2} '/'' \\_,----' + ${c2} '/'' ,;/'' + ${c2} \`\`;' EOF ;; From a2ea20dc27a23dbcfdb968884466716559e54c4f Mon Sep 17 00:00:00 2001 From: Hunter Peavey Date: Sun, 26 Apr 2020 14:06:31 -0700 Subject: [PATCH 49/73] Recenter GNU ASCII goatee --- pfetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 209100c..a9a9997 100755 --- a/pfetch +++ b/pfetch @@ -1125,8 +1125,8 @@ get_ascii() { ${c2} ,'/' ..- .\\,-.| ${c2} /'/' \\(( \\\` ./ ) ${c2} '/'' \\_,----' - ${c2} '/'' ,;/'' - ${c2} \`\`;' + ${c2} '/'' ,;/'' + ${c2} \`\`;' EOF ;; From 21af548b6c8bd55888cc6afe3af3d6b69471d318 Mon Sep 17 00:00:00 2001 From: Hunter Peavey Date: Sun, 26 Apr 2020 14:09:46 -0700 Subject: [PATCH 50/73] Changed GNU ASCII to make head slightly rounder and less blocky --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index a9a9997..183f9ea 100755 --- a/pfetch +++ b/pfetch @@ -1121,7 +1121,7 @@ get_ascii() { ${c2}./ /_._ _._\\ \\. ${c2}: _/_._\`:'_._\\_ : ${c2}\\:._/ ,\` \\ \\ \\_.:/ - ${c2} ,-';'.@) \\ @) | + ${c2} ,-';'.@) \\ @) \\ ${c2} ,'/' ..- .\\,-.| ${c2} /'/' \\(( \\\` ./ ) ${c2} '/'' \\_,----' From 1713dc68a18ba0ceed1e46e889ad6d9f01db1ae7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 29 May 2020 09:58:05 +0300 Subject: [PATCH 51/73] pfetch: Fix WSL. Closes #57 --- pfetch | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pfetch b/pfetch index 2b13b9b..a446662 100755 --- a/pfetch +++ b/pfetch @@ -195,8 +195,8 @@ get_os() { # # If the kernel version string ends in "-Microsoft", # we're very likely running under Windows 10 in WSL1. - [ "${kernel%%*-Microsoft}" ] || - distro="$distro on Windows 10 [WSL1]" + if [ "$WSLENV" ]; then + distro="${distro}${WSLENV+ on Windows 10 [WSL2]}" # Check to see if Linux is running in Windows 10 under # WSL2 (Windows subsystem for Linux [version 2]) and @@ -205,7 +205,9 @@ get_os() { # This checks to see if '$WSLENV' is defined. This # appends the Windows 10 string even if '$WSLENV' is # empty. We only need to check that is has been _exported_. - distro="${distro}${WSLENV+ on Windows 10 [WSL2]}" + elif [ -z "${kernel%%*-Microsoft}" ]; then + distro="$distro on Windows 10 [WSL1]" + fi ;; Darwin*) @@ -296,8 +298,8 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) - return + *BSD*|Haiku|Minix) + return ;; esac @@ -426,7 +428,7 @@ get_uptime() { # Split the pretty output into days or hours # based on the uptime. - case $t in + case $t in *-*) d=${t%%-*} t=${t#*-} ;; *:*:*) h=${t%%:*} t=${t#*:} ;; esac @@ -750,10 +752,10 @@ get_memory() { # Example output: Memory: 160M max, 147M avail, ..... while IFS=' :' read -r label mem_full _ mem_free _; do case $label in - Memory) + Memory) mem_full=${mem_full%M} mem_free=${mem_free%M} - break + break ;; esac done <<-EOF @@ -913,7 +915,7 @@ get_palette() { # Print the palette with a new-line before and afterwards. printf '\n' >&6 - log "$palette + log "$palette " " " >&6 } @@ -1454,7 +1456,7 @@ get_ascii() { main() { [ "$1" = --version ] && { - printf 'pfetch 0.7.0\n' + printf 'pfetch 0.7.0\n' exit } From aa511c1820d84328da82a7ce4251d1b1b31efc32 Mon Sep 17 00:00:00 2001 From: jn64 <23169302+jn64@users.noreply.github.com> Date: Sun, 31 May 2020 16:08:10 +0800 Subject: [PATCH 52/73] Add OpenSUSE Tumbleweed logo Reference art: --- pfetch | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pfetch b/pfetch index a446662..b5c3e1f 100755 --- a/pfetch +++ b/pfetch @@ -1299,6 +1299,16 @@ get_ascii() { EOF ;; + [Oo]pen[Ss][Uu][Ss][Ee]*[Tt]umbleweed*) + read_ascii 2 <<-EOF + ${c2} _____ ______ + ${c2} / ____\\ / ____ \\ + ${c2}/ / \`/ / \\ \\ + ${c2}\\ \\____/ /,____/ / + ${c2} \\______/ \\_____/ + EOF + ;; + [Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*) read_ascii 2 <<-EOF ${c2} _______ From 0c428389ad525759fdbef5e51d3e33a98d74dbdc Mon Sep 17 00:00:00 2001 From: jn64 <23169302+jn64@users.noreply.github.com> Date: Sun, 31 May 2020 17:25:06 +0800 Subject: [PATCH 53/73] Add KDE Neon logo Reference art: --- pfetch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pfetch b/pfetch index a446662..8c49de9 100755 --- a/pfetch +++ b/pfetch @@ -1165,6 +1165,17 @@ get_ascii() { EOF ;; + [Kk][Dd][Ee]*[Nn]eon*) + read_ascii 6 <<-EOF + ${c7} .${c6}__${c7}.${c6}__${c7}. + ${c6} / _${c7}.${c6}_ \\ + ${c6} / / \\ \\ + ${c7} . ${c6}| ${c7}O${c6} | ${c7}. + ${c6} \\ \\_${c7}.${c6}_/ / + ${c6} \\${c7}.${c6}__${c7}.${c6}__${c7}.${c6}/ + EOF + ;; + [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ From 6bd760a5c5c7ba6f9b02681d633892e6ab25e909 Mon Sep 17 00:00:00 2001 From: gkeep Date: Sun, 31 May 2020 14:42:29 +0300 Subject: [PATCH 54/73] Add Raspbian logo --- pfetch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pfetch b/pfetch index e13cd50..4f2b346 100755 --- a/pfetch +++ b/pfetch @@ -1380,6 +1380,17 @@ get_ascii() { EOF ;; + [Rr]aspbian*) + read_ascii 1 <<-EOF + ${c1} __ __ + ${c1} (_\\)(/_) + ${c2} (_(__)_) + ${c2}(_(_)(_)_) + ${c2} (_(__)_) + ${c2} (__) + EOF + ;; + [Ss]lackware*) read_ascii 4 <<-EOF ${c4} ________ From 06ccd3d0b042ce41011fafd5172e54b4f4d4085a Mon Sep 17 00:00:00 2001 From: depsterr Date: Sun, 5 Jul 2020 05:54:14 +0200 Subject: [PATCH 55/73] Makefile: removed space between m flag and mode because of portability --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd750f2..6ec291d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: @echo RUN \'make install\' to install pfetch install: - @install -Dm 755 pfetch $(DESTDIR)$(PREFIX)/bin/pfetch + @install -Dm755 pfetch $(DESTDIR)$(PREFIX)/bin/pfetch uninstall: @rm -f $(DESTDIR)$(PREFIX)/bin/pfetch From a29c4c950a04a6d9b3ecc1361ce81dd7f2bcf10a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 5 Aug 2020 08:18:25 +0300 Subject: [PATCH 56/73] fix Endeavour OS ascii. Closes #68 --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index a446662..8669e4c 100755 --- a/pfetch +++ b/pfetch @@ -1071,7 +1071,7 @@ get_ascii() { [Ee]ndeavour*) read_ascii 4 <<-EOF - ${c1}/${c4}\\ + ${c1}/${c4}\\ ${c1}/${c4}/ \\${c6}\\ ${c1}/${c4}/ \\ ${c6}\\ ${c1}/ ${c4}/ _) ${c6}) From c6e68d053e8056d386812b832c8432d838d24b8d Mon Sep 17 00:00:00 2001 From: TheThunderGuyS Date: Sun, 9 Aug 2020 10:50:04 -0400 Subject: [PATCH 57/73] Fix dylanaraps/pfetch issue #69 Swap colors of Raspbian logo. --- pfetch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pfetch b/pfetch index ed3687d..7b0f77c 100755 --- a/pfetch +++ b/pfetch @@ -1398,12 +1398,12 @@ get_ascii() { [Rr]aspbian*) read_ascii 1 <<-EOF - ${c1} __ __ - ${c1} (_\\)(/_) - ${c2} (_(__)_) - ${c2}(_(_)(_)_) - ${c2} (_(__)_) - ${c2} (__) + ${c2} __ __ + ${c2} (_\\)(/_) + ${c1} (_(__)_) + ${c1}(_(_)(_)_) + ${c1} (_(__)_) + ${c1} (__) EOF ;; From 34651541317fc2523be49009b6f252a81a7752f9 Mon Sep 17 00:00:00 2001 From: Tian Yuanhao Date: Fri, 4 Sep 2020 14:59:08 +0800 Subject: [PATCH 58/73] pfetch: add Buildroot logo --- pfetch | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pfetch b/pfetch index 7b0f77c..625e9e1 100755 --- a/pfetch +++ b/pfetch @@ -1023,6 +1023,16 @@ get_ascii() { EOF ;; + [Bb]uildroot*) + read_ascii 3 <<-EOF + ${c3} ___ + ${c3} / \` \\ + ${c3}| : :| + ${c3}-. _:__.- + ${c3} \` ---- \` + EOF + ;; + [Cc]ent[Oo][Ss]*) read_ascii 5 <<-EOF ${c2} ____${c3}^${c5}____ From 7a3396ecd377b4229bb04b25ea95edad878c8452 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 17 Sep 2020 08:26:38 +0300 Subject: [PATCH 59/73] packages: add carbs support --- pfetch | 1 + 1 file changed, 1 insertion(+) diff --git a/pfetch b/pfetch index 625e9e1..755ad2a 100755 --- a/pfetch +++ b/pfetch @@ -491,6 +491,7 @@ get_pkgs() { # Directories containing packages. has kiss && printf '%s\n' /var/db/kiss/installed/*/ + has cpt-list && printf '%s\n' /var/db/cpt/installed/*/ has brew && printf '%s\n' "$(brew --cellar)/"* has emerge && printf '%s\n' /var/db/pkg/*/*/ has pkgtool && printf '%s\n' /var/log/packages/* From 0faef36de92a0bafbdb9ea88da9f7aa9b8c6dd63 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 30 Sep 2020 07:52:41 +0300 Subject: [PATCH 60/73] pfetch: Fix #76 --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 755ad2a..aca4278 100755 --- a/pfetch +++ b/pfetch @@ -77,7 +77,7 @@ log() { # Move the cursor to the right, the width of the ascii art with an # additional gap for text spacing. - printf '[%sC' "${ascii_width--1}" + printf '[%sC' "$ascii_width" # Print the info name and color the text. printf '[3%s;1m%s' "${PF_COL1-4}" "$name" From b4ec68fded8ed81c478ddfa79ad77174bd84937f Mon Sep 17 00:00:00 2001 From: TpaeFawzen <30316430+GH-TpaeFawzen@users.noreply.github.com> Date: Mon, 26 Oct 2020 22:43:26 +0900 Subject: [PATCH 61/73] added right paren to case-in patterns --- pfetch | 257 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 129 insertions(+), 128 deletions(-) diff --git a/pfetch b/pfetch index aca4278..694bfe7 100755 --- a/pfetch +++ b/pfetch @@ -128,7 +128,7 @@ get_os() { } case $os in - Linux*) + (Linux*) # Some Linux distributions (which are based on others) # fail to identify as they **do not** change the upstream # distribution's identification packages or files. @@ -167,7 +167,7 @@ get_os() { # the file contents as plain-text. while IFS='=' read -r key val; do case $key in - PRETTY_NAME) distro=$val ;; + (PRETTY_NAME) distro=$val ;; esac done < /etc/os-release fi @@ -186,7 +186,7 @@ get_os() { # very unique. This simply checks to see if the user's # PATH contains a Bedrock specific value. case $PATH in - */bedrock/cross/*) distro='Bedrock Linux' + (*/bedrock/cross/*) distro='Bedrock Linux' esac # Check to see if Linux is running in Windows 10 under @@ -210,7 +210,7 @@ get_os() { fi ;; - Darwin*) + (Darwin*) # Parse the SystemVersion.plist file to grab the macOS # version. The file is in the following format: # @@ -238,31 +238,31 @@ get_os() { # the system has. As far as I'm aware there's no "dynamic" way # of grabbing this information. case $mac_version in - 10.4*) distro='Mac OS X Tiger' ;; - 10.5*) distro='Mac OS X Leopard' ;; - 10.6*) distro='Mac OS X Snow Leopard' ;; - 10.7*) distro='Mac OS X Lion' ;; - 10.8*) distro='OS X Mountain Lion' ;; - 10.9*) distro='OS X Mavericks' ;; - 10.10*) distro='OS X Yosemite' ;; - 10.11*) distro='OS X El Capitan' ;; - 10.12*) distro='macOS Sierra' ;; - 10.13*) distro='macOS High Sierra' ;; - 10.14*) distro='macOS Mojave' ;; - 10.15*) distro='macOS Catalina' ;; - *) distro='macOS' ;; + (10.4*) distro='Mac OS X Tiger' ;; + (10.5*) distro='Mac OS X Leopard' ;; + (10.6*) distro='Mac OS X Snow Leopard' ;; + (10.7*) distro='Mac OS X Lion' ;; + (10.8*) distro='OS X Mountain Lion' ;; + (10.9*) distro='OS X Mavericks' ;; + (10.10*) distro='OS X Yosemite' ;; + (10.11*) distro='OS X El Capitan' ;; + (10.12*) distro='macOS Sierra' ;; + (10.13*) distro='macOS High Sierra' ;; + (10.14*) distro='macOS Mojave' ;; + (10.15*) distro='macOS Catalina' ;; + (*) distro='macOS' ;; esac distro="$distro $mac_version" ;; - Haiku) + (Haiku) # Haiku uses 'uname -v' for version information # instead of 'uname -r' which only prints '1'. distro=$(uname -sv) ;; - Minix|DragonFly) + (Minix|DragonFly) distro="$os $kernel" # Minix and DragonFly don't support the escape @@ -270,13 +270,13 @@ get_os() { trap '' EXIT ;; - SunOS) + (SunOS) # Grab the first line of the '/etc/release' file # discarding everything after '('. IFS='(' read -r distro _ < /etc/release ;; - OpenBSD*) + (OpenBSD*) # Show the OpenBSD version type (current if present). # kern.version=OpenBSD 6.6-current (GENERIC.MP) ... IFS=' =' read -r _ distro openbsd_ver _ <<-EOF @@ -286,7 +286,7 @@ get_os() { distro="$distro $openbsd_ver" ;; - *) + (*) # Catch all to ensure '$distro' is never blank. # This also handles the BSDs. distro="$os $kernel" @@ -298,7 +298,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) + (*BSD*|Haiku|Minix) return ;; esac @@ -309,7 +309,7 @@ get_kernel() { get_host() { case $os in - Linux*) + (Linux*) # Despite what these files are called, version doesn't # always contain the version nor does name always contain # the name. @@ -320,20 +320,20 @@ get_host() { host="$name $version $model" ;; - Darwin*|FreeBSD*|DragonFly*) + (Darwin*|FreeBSD*|DragonFly*) host=$(sysctl -n hw.model) ;; - NetBSD*) + (NetBSD*) host=$(sysctl -n machdep.dmi.system-vendor \ machdep.dmi.system-product) ;; - OpenBSD*) + (OpenBSD*) host=$(sysctl -n hw.version) ;; - *BSD*|Minix) + (*BSD*|Minix) host=$(sysctl -n hw.vendor hw.product) ;; esac @@ -366,7 +366,7 @@ get_host() { # found in the "blacklist" below. Only non-matches are appended # to the final host string. case $word in - To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\ + (To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\ Not | Applicable | Specified | System | Product | Name |\ Version | Undefined | Default | string | INVALID | � | os ) continue @@ -385,7 +385,7 @@ get_uptime() { # converting that data into days, hours and minutes using simple # math. case $os in - Linux*|Minix*) + (Linux*|Minix*) IFS=. read -r s _ < /proc/uptime ;; @@ -402,13 +402,13 @@ get_uptime() { s=$(($(date +%s) - s)) ;; - Haiku) + (Haiku) # The boot time is returned in microseconds, convert it to # regular seconds. s=$(($(system_time) / 1000000)) ;; - SunOS) + (SunOS) # Split the output of 'kstat' on '.' and any white-space # which exists in the command output. # @@ -421,7 +421,7 @@ get_uptime() { EOF ;; - IRIX) + (IRIX) # Grab the uptime in a pretty format. Usually, # 00:00:00 from the 'ps' command. t=$(LC_ALL=POSIX ps -o etime= -p 1) @@ -429,8 +429,8 @@ get_uptime() { # Split the pretty output into days or hours # based on the uptime. case $t in - *-*) d=${t%%-*} t=${t#*-} ;; - *:*:*) h=${t%%:*} t=${t#*:} ;; + (*-*) d=${t%%-*} t=${t#*-} ;; + (*:*:*) h=${t%%:*} t=${t#*:} ;; esac h=${h#0} t=${t#0} @@ -447,9 +447,9 @@ get_uptime() { m=$((s / 60 % 60)) # Only append days, hours and minutes if they're non-zero. - [ "$d" = 0 ] || uptime="${uptime}${d}d " - [ "$h" = 0 ] || uptime="${uptime}${h}h " - [ "$m" = 0 ] || uptime="${uptime}${m}m " + case "$d" in ([!0]*) uptime="${uptime}${d}d "; esac + case "$h" in ([!0]*) uptime="${uptime}${h}h "; esac + case "$m" in ([!0]*) uptime="${uptime}${m}m "; esac log uptime "${uptime:-0m}" >&6 } @@ -477,7 +477,7 @@ get_pkgs() { # shellcheck disable=2006 packages=` case $os in - Linux*) + (Linux*) # Commands which print packages one per line. has bonsai && bonsai list has crux && pkginfo -i @@ -504,7 +504,7 @@ get_pkgs() { } ;; - Darwin*) + (Darwin*) # Commands which print packages one per line. has pkgin && pkgin list @@ -522,37 +522,38 @@ get_pkgs() { has port && { pkg_list=$(port installed) - [ "$pkg_list" = "No ports are installed." ] || + case "$pkg_list" in ("No ports are installed.") :;; (*) printf '%s\n' "$pkg_list" + esac } ;; - FreeBSD*|DragonFly*) + (FreeBSD*|DragonFly*) pkg info ;; - OpenBSD*) + (OpenBSD*) printf '%s\n' /var/db/pkg/*/ ;; - NetBSD*) + (NetBSD*) pkg_info ;; - Haiku) + (Haiku) printf '%s\n' /boot/system/package-links/* ;; - Minix) + (Minix) printf '%s\n' /usr/pkg/var/db/pkg/*/ ;; - SunOS) + (SunOS) has pkginfo && pkginfo -i has pkg && pkg list ;; - IRIX) + (IRIX) versions -b ;; esac | wc -l @@ -561,10 +562,10 @@ get_pkgs() { case $os in # IRIX's package manager adds 3 lines of extra # output which we must account for here. - IRIX) packages=$((packages - 3)) ;; + (IRIX) packages=$((packages - 3)) ;; esac - [ "$packages" -gt 1 ] && log pkgs "$packages" >&6 + case "$packages" in (0|1|-*) :;; (*) log pkgs "$packages" >&6;; esac } get_memory() { @@ -572,22 +573,22 @@ get_memory() { # Used memory is calculated using the following "formula": # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable # Source: https://github.com/KittyKatt/screenFetch/issues/386 - Linux*) + (Linux*) # Parse the '/proc/meminfo' file splitting on ':' and 'k'. # The format of the file is 'key: 000kB' and an additional # split is used on 'k' to filter out 'kB'. while IFS=':k ' read -r key val _; do case $key in - MemTotal) + (MemTotal) mem_used=$((mem_used + val)) mem_full=$val ;; - Shmem) + (Shmem) mem_used=$((mem_used + val)) ;; - MemFree|Buffers|Cached|SReclaimable) + (MemFree|Buffers|Cached|SReclaimable) mem_used=$((mem_used - val)) ;; esac @@ -599,7 +600,7 @@ get_memory() { # Used memory is calculated using the following "formula": # (wired + active + occupied) * 4 / 1024 - Darwin*) + (Darwin*) mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) # Parse the 'vmstat' file splitting on ':' and '.'. @@ -607,7 +608,7 @@ get_memory() { # split is used on '.' to filter it out. while IFS=:. read -r key val; do case $key in - *' wired'*|*' active'*|*' occupied'*) + (*' wired'*|*' active'*|*' occupied'*) mem_used=$((mem_used + ${val:-0})) ;; esac @@ -623,7 +624,7 @@ get_memory() { mem_used=$((mem_used * 4 / 1024)) ;; - OpenBSD*) + (OpenBSD*) mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) # This is a really simpler parser for 'vmstat' which grabs @@ -649,7 +650,7 @@ get_memory() { # Used memory is calculated using the following "formula": # mem_full - ((inactive + free + cache) * page_size / 1024) - FreeBSD*|DragonFly*) + (FreeBSD*|DragonFly*) mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) # Use 'set --' to store the output of the command in the @@ -674,14 +675,14 @@ get_memory() { mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024))) ;; - NetBSD*) + (NetBSD*) mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) # 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 case $key in - MemFree) + (MemFree) mem_free=$((val / 1024)) break ;; @@ -691,7 +692,7 @@ get_memory() { mem_used=$((mem_full - mem_free)) ;; - Haiku) + (Haiku) # Read the first line of 'sysinfo -mem' splitting on # '(', ' ', and ')'. The needed information is then # stored in the 5th and 7th elements. Using '_' "consumes" @@ -707,7 +708,7 @@ get_memory() { mem_full=$((mem_full / 1024 / 1024)) ;; - Minix) + (Minix) # Minix includes the '/proc' filesystem though the format # differs from Linux. The '/proc/meminfo' file is only a # single line with space separated elements and elements @@ -718,7 +719,7 @@ get_memory() { mem_full=$(( mem_full / 1024)) ;; - SunOS) + (SunOS) hw_pagesize=$(pagesize) # 'kstat' outputs memory in the following format: @@ -732,8 +733,8 @@ get_memory() { # A variable is then assigned based on the key. while read -r key val; do case $key in - *total) pages_full=$val ;; - *free) pages_free=$val ;; + (*total) pages_full=$val ;; + (*free) pages_free=$val ;; esac done <<-EOF $(kstat -p unix:0:system_pages:pagestotal \ @@ -745,7 +746,7 @@ get_memory() { mem_used=$((mem_full - mem_free)) ;; - IRIX) + (IRIX) # Read the memory information from the 'top' command. Parse # and split each line until we reach the line starting with # "Memory". @@ -753,7 +754,7 @@ get_memory() { # Example output: Memory: 160M max, 147M avail, ..... while IFS=' :' read -r label mem_full _ mem_free _; do case $label in - Memory) + (Memory) mem_full=${mem_full%M} mem_free=${mem_free%M} break @@ -773,9 +774,9 @@ get_memory() { get_wm() { case $os in # Don't display window manager on macOS. - Darwin*) ;; + (Darwin*) ;; - *) + (*) # xprop can be used to grab the window manager's properties # which contains the window manager's name under '_NET_WM_NAME'. # @@ -853,24 +854,24 @@ get_wm() { # Handle cases of a window manager _not_ populating the # '_NET_WM_NAME' atom. Display nothing in this case. case $wm in - *'_NET_WM_NAME = '*) + (*'_NET_WM_NAME = '*) wm=${wm##*_NET_WM_NAME = \"} wm=${wm%%\"*} ;; - *) + (*) # Fallback to checking the process list # for the select few window managers which # don't set '_NET_WM_NAME'. while read -r ps_line; do case $ps_line in - *catwm*) wm=catwm ;; - *fvwm*) wm=fvwm ;; - *dwm*) wm=dwm ;; - *2bwm*) wm=2bwm ;; - *monsterwm*) wm=monsterwm ;; - *wmaker*) wm='Window Maker' ;; - *sowm*) wm=sowm ;; + (*catwm*) wm=catwm ;; + (*fvwm*) wm=fvwm ;; + (*dwm*) wm=dwm ;; + (*2bwm*) wm=2bwm ;; + (*monsterwm*) wm=monsterwm ;; + (*wmaker*) wm='Window Maker' ;; + (*sowm*) wm=sowm ;; esac done <<-EOF $(ps x) @@ -957,7 +958,7 @@ get_ascii() { # allows indentation to continue naturally despite # the use of '<<-EOF'. case ${1:-${PF_ASCII:-${distro:-$os}}} in - [Aa]lpine*) + ([Aa]lpine*) read_ascii 4 <<-EOF ${c4} /\\ /\\ /${c7}/ ${c4}\\ \\ @@ -968,7 +969,7 @@ get_ascii() { EOF ;; - [Aa]ndroid*) + ([Aa]ndroid*) read_ascii 2 <<-EOF ${c2} ;, ,; ${c2} ';,.-----.,;' @@ -979,7 +980,7 @@ get_ascii() { EOF ;; - [Aa]rch*) + ([Aa]rch*) read_ascii 4 <<-EOF ${c6} /\\ ${c6} / \\ @@ -991,7 +992,7 @@ get_ascii() { EOF ;; - [Aa]rco*) + ([Aa]rco*) read_ascii 4 <<-EOF ${c4} /\\ ${c4} / \\ @@ -1003,7 +1004,7 @@ get_ascii() { EOF ;; - [Aa]rtix*) + ([Aa]rtix*) read_ascii 6 <<-EOF ${c4} /\\ ${c4} / \\ @@ -1015,7 +1016,7 @@ get_ascii() { EOF ;; - [Bb]edrock*) + ([Bb]edrock*) read_ascii 4 <<-EOF ${c7}__ ${c7}\\ \\___ @@ -1024,7 +1025,7 @@ get_ascii() { EOF ;; - [Bb]uildroot*) + ([Bb]uildroot*) read_ascii 3 <<-EOF ${c3} ___ ${c3} / \` \\ @@ -1034,7 +1035,7 @@ get_ascii() { EOF ;; - [Cc]ent[Oo][Ss]*) + ([Cc]ent[Oo][Ss]*) read_ascii 5 <<-EOF ${c2} ____${c3}^${c5}____ ${c2} |\\ ${c3}|${c5} /| @@ -1046,7 +1047,7 @@ get_ascii() { EOF ;; - [Dd]ebian*) + ([Dd]ebian*) read_ascii 1 <<-EOF ${c1} _____ ${c1} / __ \\ @@ -1057,7 +1058,7 @@ get_ascii() { EOF ;; - [Dd]ragon[Ff]ly*) + ([Dd]ragon[Ff]ly*) read_ascii 1 <<-EOF ,${c1}_${c7}, ('-_${c1}|${c7}_-') @@ -1069,7 +1070,7 @@ get_ascii() { EOF ;; - [Ee]lementary*) + ([Ee]lementary*) read_ascii <<-EOF ${c7} _______ ${c7} / ____ \\ @@ -1080,7 +1081,7 @@ get_ascii() { EOF ;; - [Ee]ndeavour*) + ([Ee]ndeavour*) read_ascii 4 <<-EOF ${c1}/${c4}\\ ${c1}/${c4}/ \\${c6}\\ @@ -1091,7 +1092,7 @@ get_ascii() { EOF ;; - [Ff]edora*) + ([Ff]edora*) read_ascii 4 <<-EOF ${c7} _____ / __)${c4}\\${c7} @@ -1104,7 +1105,7 @@ get_ascii() { EOF ;; - [Ff]ree[Bb][Ss][Dd]*) + ([Ff]ree[Bb][Ss][Dd]*) read_ascii 1 <<-EOF ${c1}/\\,-'''''-,/\\ ${c1}\\_) (_/ @@ -1115,7 +1116,7 @@ get_ascii() { EOF ;; - [Gg]entoo*) + ([Gg]entoo*) read_ascii 5 <<-EOF ${c5} _-----_ ${c5}( \\ @@ -1127,7 +1128,7 @@ get_ascii() { EOF ;; - [Gg][Nn][Uu]*) + ([Gg][Nn][Uu]*) read_ascii 3 <<-EOF ${c2} _-\`\`-, ,-\`\`-_ ${c2} .' _-_| |_-_ '. @@ -1143,7 +1144,7 @@ get_ascii() { EOF ;; - [Gg]uix[Ss][Dd]*|[Gg]uix*) + ([Gg]uix[Ss][Dd]*|[Gg]uix*) read_ascii 3 <<-EOF ${c3}|.__ __.| ${c3}|__ \\ / __| @@ -1155,7 +1156,7 @@ get_ascii() { EOF ;; - [Hh]aiku*) + ([Hh]aiku*) read_ascii 3 <<-EOF ${c3} ,^, ${c3} / \\ @@ -1168,7 +1169,7 @@ get_ascii() { EOF ;; - [Hh]yperbola*) + ([Hh]yperbola*) read_ascii <<-EOF ${c7} |\`__.\`/ ${c7} \____/ @@ -1180,7 +1181,7 @@ get_ascii() { EOF ;; - [Ii][Rr][Ii][Xx]*) + ([Ii][Rr][Ii][Xx]*) read_ascii 1 <<-EOF ${c1} __ ${c1} \\ \\ __ @@ -1192,7 +1193,7 @@ get_ascii() { EOF ;; - [Kk][Dd][Ee]*[Nn]eon*) + ([Kk][Dd][Ee]*[Nn]eon*) read_ascii 6 <<-EOF ${c7} .${c6}__${c7}.${c6}__${c7}. ${c6} / _${c7}.${c6}_ \\ @@ -1203,7 +1204,7 @@ get_ascii() { EOF ;; - [Ll]inux*[Ll]ite*|[Ll]ite*) + ([Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ ${c3} / \\ @@ -1215,7 +1216,7 @@ get_ascii() { EOF ;; - [Ll]inux*[Mm]int*|[Mm]int) + ([Ll]inux*[Mm]int*|[Mm]int) read_ascii 2 <<-EOF ${c2} ___________ ${c2}|_ \\ @@ -1228,7 +1229,7 @@ get_ascii() { ;; - [Ll]inux*) + ([Ll]inux*) read_ascii 4 <<-EOF ${c4} ___ ${c4}(${c7}.. ${c4}| @@ -1240,7 +1241,7 @@ get_ascii() { EOF ;; - [Mm]ac[Oo][Ss]*|[Dd]arwin*) + ([Mm]ac[Oo][Ss]*|[Dd]arwin*) read_ascii 1 <<-EOF ${c1} .:' ${c1} _ :'_ @@ -1252,7 +1253,7 @@ get_ascii() { EOF ;; - [Mm]ageia*) + ([Mm]ageia*) read_ascii 2 <<-EOF ${c6} * ${c6} * @@ -1264,7 +1265,7 @@ get_ascii() { EOF ;; - [Mm]anjaro*) + ([Mm]anjaro*) read_ascii 2 <<-EOF ${c2}||||||||| |||| ${c2}||||||||| |||| @@ -1276,7 +1277,7 @@ get_ascii() { EOF ;; - [Mm]inix*) + ([Mm]inix*) read_ascii 4 <<-EOF ${c4} ,, ,, ${c4};${c7},${c4} ', ,' ${c7},${c4}; @@ -1289,7 +1290,7 @@ get_ascii() { EOF ;; - [Mm][Xx]*) + ([Mm][Xx]*) read_ascii <<-EOF ${c7} \\\\ / ${c7} \\\\/ @@ -1301,7 +1302,7 @@ get_ascii() { EOF ;; - [Nn]et[Bb][Ss][Dd]*) + ([Nn]et[Bb][Ss][Dd]*) read_ascii 3 <<-EOF ${c7}\\\\${c3}\`-______,----__ ${c7} \\\\ ${c3}__,---\`_ @@ -1313,7 +1314,7 @@ get_ascii() { EOF ;; - [Nn]ix[Oo][Ss]*) + ([Nn]ix[Oo][Ss]*) read_ascii 4 <<-EOF ${c4} \\\\ \\\\ // ${c4} ==\\\\__\\\\/ // @@ -1325,7 +1326,7 @@ get_ascii() { EOF ;; - [Oo]pen[Bb][Ss][Dd]*) + ([Oo]pen[Bb][Ss][Dd]*) read_ascii 3 <<-EOF ${c3} _____ ${c3} \\- -/ @@ -1337,7 +1338,7 @@ get_ascii() { EOF ;; - [Oo]pen[Ss][Uu][Ss][Ee]*[Tt]umbleweed*) + ([Oo]pen[Ss][Uu][Ss][Ee]*[Tt]umbleweed*) read_ascii 2 <<-EOF ${c2} _____ ______ ${c2} / ____\\ / ____ \\ @@ -1347,7 +1348,7 @@ get_ascii() { EOF ;; - [Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*) + ([Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*) read_ascii 2 <<-EOF ${c2} _______ ${c2}__| __ \\ @@ -1359,7 +1360,7 @@ get_ascii() { EOF ;; - [Oo]pen[Ww]rt*) + ([Oo]pen[Ww]rt*) read_ascii 1 <<-EOF ${c1} _______ ${c1}| |.-----.-----.-----. @@ -1372,7 +1373,7 @@ get_ascii() { EOF ;; - [Pp]arabola*) + ([Pp]arabola*) read_ascii 5 <<-EOF ${c5} __ __ __ _ ${c5}.\`_//_//_/ / \`. @@ -1383,7 +1384,7 @@ get_ascii() { EOF ;; - [Pp]op!_[Oo][Ss]*) + ([Pp]op!_[Oo][Ss]*) read_ascii 6 <<-EOF ${c6}______ ${c6}\\ _ \\ __ @@ -1396,7 +1397,7 @@ get_ascii() { EOF ;; - [Pp]ure[Oo][Ss]*) + ([Pp]ure[Oo][Ss]*) read_ascii <<-EOF ${c7} _____________ ${c7}| _________ | @@ -1407,7 +1408,7 @@ get_ascii() { EOF ;; - [Rr]aspbian*) + ([Rr]aspbian*) read_ascii 1 <<-EOF ${c2} __ __ ${c2} (_\\)(/_) @@ -1418,7 +1419,7 @@ get_ascii() { EOF ;; - [Ss]lackware*) + ([Ss]lackware*) read_ascii 4 <<-EOF ${c4} ________ ${c4} / ______| @@ -1430,7 +1431,7 @@ get_ascii() { EOF ;; - [Ss]un[Oo][Ss]|[Ss]olaris*) + ([Ss]un[Oo][Ss]|[Ss]olaris*) read_ascii 3 <<-EOF ${c3} . .; . ${c3} . :; :: ;: . @@ -1440,7 +1441,7 @@ get_ascii() { EOF ;; - [Uu]buntu*) + ([Uu]buntu*) read_ascii 3 <<-EOF ${c3} _ ${c3} ---(_) @@ -1451,7 +1452,7 @@ get_ascii() { EOF ;; - [Vv]oid*) + ([Vv]oid*) read_ascii 2 <<-EOF ${c2} _______ ${c2} _ \\______ - @@ -1463,7 +1464,7 @@ get_ascii() { EOF ;; - *) + (*) # On no match of a distribution ascii art, this function calls # itself again, this time to look for a more generic OS related # ascii art (KISS Linux -> Linux). @@ -1514,14 +1515,16 @@ get_ascii() { } main() { - [ "$1" = --version ] && { + case "$1" in (--version) { printf 'pfetch 0.7.0\n' exit } # Hide 'stderr' unless the first argument is '-v'. This saves # polluting the script with '2>/dev/null'. - [ "$1" = -v ] || exec 2>/dev/null + ;;(-v) : + ;;(*) exec 2>/dev/null + ;;esac # Hide 'stdout' and selectively print to it using '>&6'. # This gives full control over what it displayed on the screen. @@ -1552,15 +1555,13 @@ main() { # Some terminals don't support these sequences, nor do they # silently conceal them if they're printed resulting in # partial sequences being printed to the terminal! - [ "$TERM" = dumb ] || - [ "$TERM" = minix ] || - [ "$TERM" = cons25 ] || { + case "$TERM" in (dumb|minix|cons25) :;;(*) # Disable line-wrapping. printf '[?7l' >&6 # Enable line-wrapping again on exit. trap 'printf [?7h >&6' EXIT - } + ;;esac # Store the output of 'uname' to avoid calling it multiple times # throughout the script. 'read < Date: Fri, 30 Oct 2020 18:47:47 +0900 Subject: [PATCH 62/73] improved [ "$packages" -gt 1 ] uninversed the condition --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 694bfe7..4a3f413 100755 --- a/pfetch +++ b/pfetch @@ -565,7 +565,7 @@ get_pkgs() { (IRIX) packages=$((packages - 3)) ;; esac - case "$packages" in (0|1|-*) :;; (*) log pkgs "$packages" >&6;; esac + case "$packages" in (1?*|[2-9]*) log pkgs "$packages" >&6;; esac } get_memory() { From 2f0a022b1f89ab0afae3bfa066ef8994796c29ac Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 1 Nov 2020 05:51:12 +0200 Subject: [PATCH 63/73] pfetch: fallback to /etc/hostname. Closes #83 --- pfetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pfetch b/pfetch index aca4278..b5e0c72 100755 --- a/pfetch +++ b/pfetch @@ -112,6 +112,10 @@ get_title() { # shellcheck disable=SC2039 hostname=${HOSTNAME:-${hostname:-$(hostname)}} + # If the hostname is still not found, fallback to the contents of the + # /etc/hostname file. + [ "$hostname" ] || read -r hostname < /etc/hostname + log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 } From 2ac2cf856a6695a1fc07075053e9074d25240158 Mon Sep 17 00:00:00 2001 From: cyrilst Date: Sun, 25 Oct 2020 19:10:15 +0100 Subject: [PATCH 64/73] pfetch: correctly display OS version of FreeBSD --- pfetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pfetch b/pfetch index 4e22558..5a140d6 100755 --- a/pfetch +++ b/pfetch @@ -290,6 +290,10 @@ get_os() { distro="$distro $openbsd_ver" ;; + FreeBSD) + distro="$os $(freebsd-version)" + ;; + (*) # Catch all to ensure '$distro' is never blank. # This also handles the BSDs. From 4bcc18e9a6e24ccf7aa095708fc277e8b1aca1f8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 3 Nov 2020 05:48:16 +0200 Subject: [PATCH 65/73] pfetch: Fix program detection when aliases/functions are also defined. Closes #84 --- pfetch | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pfetch b/pfetch index 4e22558..c8fd87c 100755 --- a/pfetch +++ b/pfetch @@ -2,6 +2,14 @@ # # pfetch - Simple POSIX sh fetch script. +# This is just a simple wrapper around 'command -v' to avoid +# spamming '>/dev/null' throughout this function. This also guards +# against aliases and functions. +has() { + _cmd=$(command -v "$1") >/dev/null || return 1 + [ -x "$_cmd" ] || return 1 +} + log() { # The 'log()' function handles the printing of information. # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info @@ -155,7 +163,7 @@ get_os() { # This applies only to distributions which follow the standard # by shipping unmodified identification files and packages # from their respective upstreams. - if command -v lsb_release; then + if has lsb_release; then distro=$(lsb_release -sd) # Android detection works by checking for the existence of @@ -183,8 +191,8 @@ get_os() { # 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' + has crux && distro=$(crux) + has guix && distro='Guix System' # Check to see if we're running Bedrock Linux which is # very unique. This simply checks to see if the user's @@ -459,10 +467,6 @@ get_uptime() { } get_pkgs() { - # This is just a simple wrapper around 'command -v' to avoid - # spamming '>/dev/null' throughout this function. - has() { command -v "$1" >/dev/null; } - # This works by first checking for which package managers are # installed and finally by printing each package manager's # package list with each package one per line. @@ -834,7 +838,7 @@ get_wm() { # This is a two pass call to xprop. One call to get the window # manager's ID and another to print its properties. - command -v xprop && { + has xprop && { # The output of the ID command is as follows: # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 # From a4f9cb96e9d6a82141beef46d4f676fa1c5b9b23 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 3 Nov 2020 05:48:58 +0200 Subject: [PATCH 66/73] oops --- pfetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfetch b/pfetch index c8fd87c..4c0c34b 100755 --- a/pfetch +++ b/pfetch @@ -6,7 +6,7 @@ # spamming '>/dev/null' throughout this function. This also guards # against aliases and functions. has() { - _cmd=$(command -v "$1") >/dev/null || return 1 + _cmd=$(command -v "$1") 2>/dev/null || return 1 [ -x "$_cmd" ] || return 1 } From 754d6c6bc9ec930f752247c13df344da85b3fd6c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 3 Nov 2020 05:57:14 +0200 Subject: [PATCH 67/73] memory: Support MemAvailable --- pfetch | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 4c0c34b..dc75bea 100755 --- a/pfetch +++ b/pfetch @@ -599,10 +599,26 @@ get_memory() { (MemFree|Buffers|Cached|SReclaimable) mem_used=$((mem_used - val)) ;; + + # If detected this will be used over the above calculation + # for mem_used. Available since Linux 3.14rc. + # See kernel commit 34e431b0ae398fc54ea69ff85ec700722c9da773 + (MemAvailable) + mem_avail=$val + ;; esac done < /proc/meminfo - mem_used=$((mem_used / 1024)) + case $mem_avail in + (*[0-9]*) + mem_used=$(((mem_full - mem_avail) / 1024)) + ;; + + *) + mem_used=$((mem_used / 1024)) + ;; + esac + mem_full=$((mem_full / 1024)) ;; From 4c059b666addbe1397db099a0927081e4a64a8c5 Mon Sep 17 00:00:00 2001 From: Quinten <58103738+HexaOneOfficial@users.noreply.github.com> Date: Fri, 6 Nov 2020 14:36:37 +0100 Subject: [PATCH 68/73] add dahlia --- pfetch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pfetch b/pfetch index dc75bea..99ad33c 100755 --- a/pfetch +++ b/pfetch @@ -1071,6 +1071,20 @@ get_ascii() { EOF ;; + ([Dd]ahlia*) + read_ascii 1 <<-EOF + ${c1} _ + ${c1} ___/ \___ + ${c1} | _-_ | + ${c1} | / \ | + ${c1}/ | | \ + ${c1}\ | | / + ${c1} | \ _ _ / | + ${c1} |___ - ___| + ${c1} \_/ + EOF + ;; + ([Dd]ebian*) read_ascii 1 <<-EOF ${c1} _____ From 45c1853b2f68f574b2a27a18a14537a54e27e4b1 Mon Sep 17 00:00:00 2001 From: Quinten <58103738+HexaOneOfficial@users.noreply.github.com> Date: Fri, 6 Nov 2020 14:37:37 +0100 Subject: [PATCH 69/73] add dahlia --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88ee53b..0c4dac0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ picture"! ## OS support - **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 and Void Linux. + - Alpine Linux, Arch Linux, Arco Linux, Artix Linux, CentOS, Dahlia, Debian, Elementary, Fedora, Gentoo, Guix, Hyperbola, KISS Linux, Linux Lite, Linux Mint, Mageia, Manjaro, MX Linux, NixOS, OpenSUSE, Parabola, Pop!\_OS, PureOS, Slackware, Ubuntu and Void Linux. - All other distributions are supported with a generic penguin logo. - **Android** - **BSD** From 71f18c30f8b480e50be82444f006f0754a10d6a4 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 7 Nov 2020 15:18:52 +0200 Subject: [PATCH 70/73] fix dahlia. See #87 --- pfetch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pfetch b/pfetch index 99ad33c..1028c65 100755 --- a/pfetch +++ b/pfetch @@ -1074,15 +1074,15 @@ get_ascii() { ([Dd]ahlia*) read_ascii 1 <<-EOF ${c1} _ - ${c1} ___/ \___ + ${c1} ___/ \\___ ${c1} | _-_ | ${c1} | / \ | - ${c1}/ | | \ - ${c1}\ | | / + ${c1}/ | | \\ + ${c1}\\ | | / ${c1} | \ _ _ / | ${c1} |___ - ___| - ${c1} \_/ - EOF + ${c1} \\_/ + EOF ;; ([Dd]ebian*) From a7aaf866090e9ee58feee35f11a9d22d1375fa11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Antoine=20Ch=C3=A9ron?= Date: Sun, 15 Nov 2020 14:15:37 +0100 Subject: [PATCH 71/73] add instantOS --- README.md | 2 +- pfetch | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c4dac0..747daa4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ picture"! ## OS support - **Linux** - - Alpine Linux, Arch Linux, Arco Linux, Artix Linux, CentOS, Dahlia, Debian, Elementary, Fedora, Gentoo, Guix, Hyperbola, KISS Linux, Linux Lite, Linux Mint, Mageia, Manjaro, MX Linux, NixOS, OpenSUSE, Parabola, Pop!\_OS, PureOS, Slackware, Ubuntu and Void Linux. + - Alpine Linux, Arch Linux, Arco Linux, Artix Linux, CentOS, Dahlia, Debian, Elementary, Fedora, Gentoo, Guix, Hyperbola, instantOS, KISS Linux, Linux Lite, Linux Mint, Mageia, Manjaro, MX Linux, NixOS, OpenSUSE, Parabola, Pop!\_OS, PureOS, Slackware, Ubuntu and Void Linux. - All other distributions are supported with a generic penguin logo. - **Android** - **BSD** diff --git a/pfetch b/pfetch index 1028c65..db211f1 100755 --- a/pfetch +++ b/pfetch @@ -1218,6 +1218,17 @@ get_ascii() { ${c7}/.\` \`.\\ EOF ;; + + ([Ii]nstant[Oo][Ss]*) + read_ascii <<-EOF + ${c0} ,-''-, + ${c0}: .''. : + ${c0}: ',,' : + ${c0} '-____:__ + ${c0} : \`. + ${c0} \`._.' + EOF + ;; ([Ii][Rr][Ii][Xx]*) read_ascii 1 <<-EOF From c225f75cc8392d933fec73889728b1beec3228e7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 Nov 2020 18:27:37 +0200 Subject: [PATCH 72/73] minor changes - all sequences now go through a wrapper. - added PF_COLOR to enable/disable colors in output. - etc, etc. Closes #89 --- README.md | 5 ++ pfetch | 198 +++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 148 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 0c4dac0..fe0fae8 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,11 @@ PF_SOURCE="" # 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 diff --git a/pfetch b/pfetch index 1028c65..d29f917 100755 --- a/pfetch +++ b/pfetch @@ -2,6 +2,51 @@ # # pfetch - Simple POSIX sh fetch script. +# Wrapper around all escape sequences used by pfetch to allow for +# greater control over which sequences are used (if any at all). +esc() { + case $1 in + CUU) e="${esc_c}[${2}A" ;; # cursor up + CUD) e="${esc_c}[${2}B" ;; # cursor down + CUF) e="${esc_c}[${2}C" ;; # cursor right + CUB) e="${esc_c}[${2}D" ;; # cursor left + + # text formatting + SGR) + case ${PF_COLOR:=1} in + (1) + e="${esc_c}[${2}m" + ;; + + (0) + # colors disabled + e= + ;; + esac + ;; + + # line wrap + DECAWM) + case $TERM in + (dumb | minix | cons25) + # not supported + e= + ;; + + (*) + e="${esc_c}[?7${2}" + ;; + esac + ;; + esac +} + +# Print a sequence to the terminal. +esc_p() { + esc "$@" + printf '%s' "$e" +} + # This is just a simple wrapper around 'command -v' to avoid # spamming '>/dev/null' throughout this function. This also guards # against aliases and functions. @@ -85,10 +130,13 @@ log() { # Move the cursor to the right, the width of the ascii art with an # additional gap for text spacing. - printf '[%sC' "$ascii_width" + esc_p CUF "$ascii_width" # Print the info name and color the text. - printf '[3%s;1m%s' "${PF_COL1-4}" "$name" + esc_p SGR "3${PF_COL1-4}"; + esc_p SGR 1 + printf '%s' "$name" + esc_p SGR 0 # Print the info name and info data separator. printf %s "$PF_SEP" @@ -96,11 +144,15 @@ log() { # Move the cursor backward the length of the *current* info name and # then move it forwards the length of the *longest* info name. This # aligns each info data line. - printf '[%sD[%sC' "${#name}" "${PF_ALIGN:-$info_length}" + esc_p CUB "${#name}" + esc_p CUF "${PF_ALIGN:-$info_length}" # Print the info data, color it and strip all leading whitespace # from the string. - printf '[3%sm%s\n' "${PF_COL2-7}" "$info" + esc_p SGR "3${PF_COL2-7}" + printf '%s' "$info" + esc_p SGR 0 + printf '\n' # Keep track of the number of times 'log()' has been run. info_height=$((${info_height:-0} + 1)) @@ -118,13 +170,26 @@ get_title() { # the intention for using it is allowing the user to overwrite the # value on invocation. # shellcheck disable=SC2039 - hostname=${HOSTNAME:-${hostname:-$(hostname)}} + host=${HOSTNAME:-${host:-$(hostname)}} # If the hostname is still not found, fallback to the contents of the # /etc/hostname file. - [ "$hostname" ] || read -r hostname < /etc/hostname - - log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 + [ "$host" ] || read -r host < /etc/hostname + + # Add escape sequences for coloring to user and host name. As we embed + # them directly in the arguments passed to log(), we cannot use esc_p(). + esc SGR 1 + user=$e$user + esc SGR "3${PF_COL3:-1}" + user=$e$user + esc SGR 1 + user=$user$e + esc SGR 1 + host=$e$host + esc SGR "3${PF_COL3:-1}" + host=$e$host + + log "${user}@${host}" " " >&6 } get_os() { @@ -179,7 +244,9 @@ get_os() { # the file contents as plain-text. while IFS='=' read -r key val; do case $key in - (PRETTY_NAME) distro=$val ;; + (PRETTY_NAME) + distro=$val + ;; esac done < /etc/os-release fi @@ -198,7 +265,9 @@ get_os() { # very unique. This simply checks to see if the user's # PATH contains a Bedrock specific value. case $PATH in - (*/bedrock/cross/*) distro='Bedrock Linux' + (*/bedrock/cross/*) + distro='Bedrock Linux' + ;; esac # Check to see if Linux is running in Windows 10 under @@ -332,7 +401,7 @@ get_host() { host="$name $version $model" ;; - (Darwin*|FreeBSD*|DragonFly*) + (Darwin* | FreeBSD* | DragonFly*) host=$(sysctl -n hw.model) ;; @@ -345,7 +414,7 @@ get_host() { host=$(sysctl -n hw.version) ;; - (*BSD*|Minix) + (*BSD* | Minix) host=$(sysctl -n hw.vendor hw.product) ;; esac @@ -373,7 +442,7 @@ get_host() { # This string reconstruction is needed as some OEMs either leave the # identification information as "To be filled by OEM", "Default", # "undefined" etc and we shouldn't print this to the screen. - for word; do + for word do # This works by reconstructing the string by excluding words # found in the "blacklist" below. Only non-matches are appended # to the final host string. @@ -397,11 +466,11 @@ get_uptime() { # converting that data into days, hours and minutes using simple # math. case $os in - (Linux*|Minix*) + (Linux* | Minix*) IFS=. read -r s _ < /proc/uptime ;; - Darwin*|*BSD*|DragonFly*) + Darwin* | *BSD* | DragonFly*) s=$(sysctl -n kern.boottime) # Extract the uptime in seconds from the following output: @@ -530,8 +599,14 @@ get_pkgs() { has port && { pkg_list=$(port installed) - case "$pkg_list" in ("No ports are installed.") :;; (*) - printf '%s\n' "$pkg_list" + case "$pkg_list" in + ("No ports are installed.") + # do nothing + ;; + + (*) + printf '%s\n' "$pkg_list" + ;; esac } ;; @@ -570,10 +645,16 @@ get_pkgs() { case $os in # IRIX's package manager adds 3 lines of extra # output which we must account for here. - (IRIX) packages=$((packages - 3)) ;; + (IRIX) + packages=$((packages - 3)) + ;; esac - case "$packages" in (1?*|[2-9]*) log pkgs "$packages" >&6;; esac + case $packages in + (1?*|[2-9]*) + log pkgs "$packages" >&6 + ;; + esac } get_memory() { @@ -596,7 +677,7 @@ get_memory() { mem_used=$((mem_used + val)) ;; - (MemFree|Buffers|Cached|SReclaimable) + (MemFree | Buffers | Cached | SReclaimable) mem_used=$((mem_used - val)) ;; @@ -757,8 +838,13 @@ get_memory() { # A variable is then assigned based on the key. while read -r key val; do case $key in - (*total) pages_full=$val ;; - (*free) pages_free=$val ;; + (*total) + pages_full=$val + ;; + + (*free) + pages_free=$val + ;; esac done <<-EOF $(kstat -p unix:0:system_pages:pagestotal \ @@ -797,8 +883,9 @@ get_memory() { get_wm() { case $os in - # Don't display window manager on macOS. - (Darwin*) ;; + (Darwin*) + # Don't display window manager on macOS. + ;; (*) # xprop can be used to grab the window manager's properties @@ -937,7 +1024,10 @@ get_palette() { # # This allows us to save hardcoding a second set of sequences # for background colors. - palette="$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " + esc SGR 7 + palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " + esc SGR 0 + palette="$palette$e" # Print the palette with a new-line before and afterwards. printf '\n' >&6 @@ -1523,7 +1613,7 @@ get_ascii() { # printing of the information through user configuration. # # Iterate over each line of the ascii art to retrieve the above - # information. The 'sed' is used to strip 'm' color codes from + # information. The 'sed' is used to strip '\033[3Xm' color codes from # the ascii art so they don't affect the width variable. while read -r line; do ascii_height=$((${ascii_height:-0} + 1)) @@ -1546,28 +1636,33 @@ get_ascii() { # Print the ascii art and position the cursor back where we # started prior to printing it. - # '[1m': Print the ascii in bold. - # '[m': Clear bold. - # '[%sA': Move the cursor up '$ascii_height' amount of lines. - printf '%s[%sA' "$ascii" "$ascii_height" >&6 + { + esc_p SGR 1 + printf '%s' "$ascii" + esc_p SGR 0 + esc_p CUU "$ascii_height" + } >&6 } main() { - case "$1" in (--version) { + [ "$1" = --version ] && { printf 'pfetch 0.7.0\n' - exit + exit 0 } # Hide 'stderr' unless the first argument is '-v'. This saves # polluting the script with '2>/dev/null'. - ;;(-v) : - ;;(*) exec 2>/dev/null - ;;esac + [ "$1" = -v ] || { + exec 2>/dev/null + } # Hide 'stdout' and selectively print to it using '>&6'. # This gives full control over what it displayed on the screen. exec 6>&1 >/dev/null + # Store raw escape sequence character for later reuse. + esc_c=$(printf '\033') + # Allow the user to execute their own script and modify or # extend pfetch's behavior. # shellcheck source=/dev/null @@ -1581,25 +1676,16 @@ main() { # Generic color list. # Disable warning about unused variables. # shellcheck disable=2034 - { - c1=''; c2='' - c3=''; c4='' - c5=''; c6='' - c7=''; c8='' - } - - # Avoid text-wrapping from wrecking the program output. - # - # Some terminals don't support these sequences, nor do they - # silently conceal them if they're printed resulting in - # partial sequences being printed to the terminal! - case "$TERM" in (dumb|minix|cons25) :;;(*) - # Disable line-wrapping. - printf '[?7l' >&6 + for _c in c1 c2 c3 c4 c5 c6 c7 c8; do + esc SGR "3${_c#?}" 0 + export "$_c=$e" + done - # Enable line-wrapping again on exit. - trap 'printf [?7h >&6' EXIT - ;;esac + # Disable line wrapping and catch the EXIT signal to enable it again + # on exit. Ideally you'd somehow query the current value and retain + # it but I'm yet to see this irk anyone. + esc_p DECAWM l >&6 + trap 'esc_p DECAWM h >&6' EXIT # Store the output of 'uname' to avoid calling it multiple times # throughout the script. 'read </dev/null || continue # This was a ternary operation but they aren't supported in @@ -1637,7 +1723,9 @@ main() { info_length=$((info_length + 1)) # Iterate over the above list and run any existing "get_" functions. - for info; do "get_$info"; done + for info do + "get_$info" + done } # Position the cursor below both the ascii art and information lines From 20763dc8ceb53327095e34998c228cb31c0afc33 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 Nov 2020 19:02:01 +0200 Subject: [PATCH 73/73] fixci --- pfetch | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pfetch b/pfetch index 5111594..96745c3 100755 --- a/pfetch +++ b/pfetch @@ -1024,10 +1024,15 @@ get_palette() { # # This allows us to save hardcoding a second set of sequences # for background colors. - esc SGR 7 - palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " - esc SGR 0 - palette="$palette$e" + # + # False positive. + # shellcheck disable=2154 + { + esc SGR 7 + palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 " + esc SGR 0 + palette="$palette$e" + } # Print the palette with a new-line before and afterwards. printf '\n' >&6 @@ -1071,6 +1076,9 @@ get_ascii() { # NOTE: Each ascii art below is indented using tabs, this # allows indentation to continue naturally despite # the use of '<<-EOF'. + # + # False positive. + # shellcheck disable=2154 case ${1:-${PF_ASCII:-${distro:-$os}}} in ([Aa]lpine*) read_ascii 4 <<-EOF @@ -1308,7 +1316,7 @@ get_ascii() { ${c7}/.\` \`.\\ EOF ;; - + ([Ii]nstant[Oo][Ss]*) read_ascii <<-EOF ${c0} ,-''-,