pfetch: simplify

This commit is contained in:
Dylan Araps 2019-09-24 13:34:05 +03:00
parent 5cd7705ad3
commit 58f5e9b573

18
pfetch
View File

@ -82,7 +82,7 @@ die() {
} }
get_title() { get_title() {
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
read -r hostname < /proc/sys/kernel/hostname read -r hostname < /proc/sys/kernel/hostname
;; ;;
@ -105,7 +105,7 @@ get_title() {
} }
get_distro() { get_distro() {
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
. /etc/os-release && distro=$PRETTY_NAME . /etc/os-release && distro=$PRETTY_NAME
;; ;;
@ -115,11 +115,11 @@ get_distro() {
} }
get_kernel() { get_kernel() {
log kernel "$kernel_version" log kernel "$kernel"
} }
get_host() { get_host() {
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
read -r model < /sys/devices/virtual/dmi/id/product_version read -r model < /sys/devices/virtual/dmi/id/product_version
;; ;;
@ -132,7 +132,7 @@ get_uptime() {
# Uptime works by retrieving the data in total seconds and then # Uptime works by retrieving the data in total seconds and then
# converting that data into days, hours and minutes using simple # converting that data into days, hours and minutes using simple
# math. # math.
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
IFS=. read -r s _ < /proc/uptime IFS=. read -r s _ < /proc/uptime
;; ;;
@ -164,7 +164,7 @@ get_packages() {
# line, giving us the total package count of whatever package # line, giving us the total package count of whatever package
# managers are installed. # managers are installed.
packages=$( packages=$(
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
# Commands which print packages one per line. # Commands which print packages one per line.
has kiss && kiss l has kiss && kiss l
@ -186,7 +186,7 @@ get_packages() {
} }
get_memory() { get_memory() {
case $kernel_name in case $os in
# Used memory is calculated using the following "formula" (Linux): # Used memory is calculated using the following "formula" (Linux):
# MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
# Source: https://github.com/KittyKatt/screenFetch/issues/386 # Source: https://github.com/KittyKatt/screenFetch/issues/386
@ -220,7 +220,7 @@ get_memory() {
} }
get_ascii() { get_ascii() {
case $kernel_name in case $os in
Linux*|GNU*) Linux*|GNU*)
ascii="\ ascii="\
${c4} ___ ${c4} ___
@ -267,7 +267,7 @@ main() {
# Store the output of 'uname' to avoid calling it multiple times # Store the output of 'uname' to avoid calling it multiple times
# throughout the script. 'read <<EOF' is the simplest way of reading # throughout the script. 'read <<EOF' is the simplest way of reading
# a command into a list of variables. # a command into a list of variables.
read -r kernel_name kernel_version <<EOF read -r os kernel <<EOF
$(uname -sr) $(uname -sr)
EOF EOF