neofetch: remove uneeded quotes

This commit is contained in:
Dylan Araps 2019-10-28 09:28:23 +02:00
parent c154aebc40
commit 85f7b7852a
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 151 additions and 152 deletions

301
neofetch
View File

@ -1074,239 +1074,238 @@ get_distro() {
} }
get_model() { get_model() {
case "$os" in case $os in
"Linux") Linux)
if [[ -d "/system/app/" && -d "/system/priv-app" ]]; then if [[ -d /system/app/ && -d /system/priv-app ]]; then
model="$(getprop ro.product.brand) $(getprop ro.product.model)" model="$(getprop ro.product.brand) $(getprop ro.product.model)"
elif [[ -f "/sys/devices/virtual/dmi/id/product_name" || elif [[ -f /sys/devices/virtual/dmi/id/product_name ||
-f "/sys/devices/virtual/dmi/id/product_version" ]]; then -f /sys/devices/virtual/dmi/id/product_version ]]; then
model="$(< /sys/devices/virtual/dmi/id/product_name)" model=$(< /sys/devices/virtual/dmi/id/product_name)
model+=" $(< /sys/devices/virtual/dmi/id/product_version)" model+=" $(< /sys/devices/virtual/dmi/id/product_version)"
elif [[ -f "/sys/firmware/devicetree/base/model" ]]; then elif [[ -f /sys/firmware/devicetree/base/model ]]; then
model="$(< /sys/firmware/devicetree/base/model)" model=$(< /sys/firmware/devicetree/base/model)
elif [[ -f "/tmp/sysinfo/model" ]]; then elif [[ -f /tmp/sysinfo/model ]]; then
model="$(< /tmp/sysinfo/model)" model=$(< /tmp/sysinfo/model)
fi fi
;; ;;
"Mac OS X") "Mac OS X")
if [[ "$(kextstat | grep -F -e "FakeSMC" -e "VirtualSMC")" != "" ]]; then if [[ $(kextstat | grep -F -e "FakeSMC" -e "VirtualSMC") != "" ]]; then
model="Hackintosh (SMBIOS: $(sysctl -n hw.model))" model="Hackintosh (SMBIOS: $(sysctl -n hw.model))"
else else
model="$(sysctl -n hw.model)" model=$(sysctl -n hw.model)
fi fi
;; ;;
"iPhone OS") "iPhone OS")
case "$kernel_machine" in case $kernel_machine in
"iPad1,1"): "iPad" ;; iPad1,1): "iPad" ;;
"iPad2,"[1-4]): "iPad 2" ;; iPad2,[1-4]): "iPad 2" ;;
"iPad3,"[1-3]): "iPad 3" ;; iPad3,[1-3]): "iPad 3" ;;
"iPad3,"[4-6]): "iPad 4" ;; iPad3,[4-6]): "iPad 4" ;;
"iPad6,1"[12]): "iPad 5" ;; iPad6,1[12]): "iPad 5" ;;
"iPad7,"[5-6]): "iPad 6" ;; iPad7,[5-6]): "iPad 6" ;;
"iPad4,"[1-3]): "iPad Air" ;; iPad4,[1-3]): "iPad Air" ;;
"iPad5,"[3-4]): "iPad Air 2" ;; iPad5,[3-4]): "iPad Air 2" ;;
"iPad11,"[3-4]): "iPad Air 3" ;; iPad11,[3-4]): "iPad Air 3" ;;
"iPad6,"[7-8]): "iPad Pro (12.9 Inch)" ;; iPad6,[7-8]): "iPad Pro (12.9 Inch)" ;;
"iPad6,"[3-4]): "iPad Pro (9.7 Inch)" ;; iPad6,[3-4]): "iPad Pro (9.7 Inch)" ;;
"iPad7,"[1-2]): "iPad Pro 2 (12.9 Inch)" ;; iPad7,[1-2]): "iPad Pro 2 (12.9 Inch)" ;;
"iPad7,"[3-4]): "iPad Pro (10.5 Inch)" ;; iPad7,[3-4]): "iPad Pro (10.5 Inch)" ;;
"iPad8,"[1-4]): "iPad Pro (11 Inch)" ;; iPad8,[1-4]): "iPad Pro (11 Inch)" ;;
"iPad8,"[5-8]): "iPad Pro 3 (12.9 Inch)" ;; iPad8,[5-8]): "iPad Pro 3 (12.9 Inch)" ;;
"iPad2,"[5-7]): "iPad mini" ;; iPad2,[5-7]): "iPad mini" ;;
"iPad4,"[4-6]): "iPad mini 2" ;; iPad4,[4-6]): "iPad mini 2" ;;
"iPad4,"[7-9]): "iPad mini 3" ;; iPad4,[7-9]): "iPad mini 3" ;;
"iPad5,"[1-2]): "iPad mini 4" ;; iPad5,[1-2]): "iPad mini 4" ;;
"iPad11,"[1-2]): "iPad mini 5" ;; iPad11,[1-2]): "iPad mini 5" ;;
"iPhone1,1"): "iPhone" ;; iPhone1,1): "iPhone" ;;
"iPhone1,2"): "iPhone 3G" ;; iPhone1,2): "iPhone 3G" ;;
"iPhone2,1"): "iPhone 3GS" ;; iPhone2,1): "iPhone 3GS" ;;
"iPhone3,"[1-3]): "iPhone 4" ;; iPhone3,[1-3]): "iPhone 4" ;;
"iPhone4,1"): "iPhone 4S" ;; iPhone4,1): "iPhone 4S" ;;
"iPhone5,"[1-2]): "iPhone 5" ;; iPhone5,[1-2]): "iPhone 5" ;;
"iPhone5,"[3-4]): "iPhone 5c" ;; iPhone5,[3-4]): "iPhone 5c" ;;
"iPhone6,"[1-2]): "iPhone 5s" ;; iPhone6,[1-2]): "iPhone 5s" ;;
"iPhone7,2"): "iPhone 6" ;; iPhone7,2): "iPhone 6" ;;
"iPhone7,1"): "iPhone 6 Plus" ;; iPhone7,1): "iPhone 6 Plus" ;;
"iPhone8,1"): "iPhone 6s" ;; iPhone8,1): "iPhone 6s" ;;
"iPhone8,2"): "iPhone 6s Plus" ;; iPhone8,2): "iPhone 6s Plus" ;;
"iPhone8,4"): "iPhone SE" ;; iPhone8,4): "iPhone SE" ;;
"iPhone9,"[13]): "iPhone 7" ;; iPhone9,[13]): "iPhone 7" ;;
"iPhone9,"[24]): "iPhone 7 Plus" ;; iPhone9,[24]): "iPhone 7 Plus" ;;
"iPhone10,"[14]): "iPhone 8" ;; iPhone10,[14]): "iPhone 8" ;;
"iPhone10,"[25]): "iPhone 8 Plus" ;; iPhone10,[25]): "iPhone 8 Plus" ;;
"iPhone10,"[36]): "iPhone X" ;; iPhone10,[36]): "iPhone X" ;;
"iPhone11,2"): "iPhone XS" ;; iPhone11,2): "iPhone XS" ;;
"iPhone11,"[46]): "iPhone XS Max" ;; iPhone11,[46]): "iPhone XS Max" ;;
"iPhone11,8"): "iPhone XR" ;; iPhone11,8): "iPhone XR" ;;
"iPod1,1"): "iPod touch" ;; iPod1,1): "iPod touch" ;;
"ipod2,1"): "iPod touch 2G" ;; ipod2,1): "iPod touch 2G" ;;
"ipod3,1"): "iPod touch 3G" ;; ipod3,1): "iPod touch 3G" ;;
"ipod4,1"): "iPod touch 4G" ;; ipod4,1): "iPod touch 4G" ;;
"ipod5,1"): "iPod touch 5G" ;; ipod5,1): "iPod touch 5G" ;;
"ipod7,1"): "iPod touch 6G" ;; ipod7,1): "iPod touch 6G" ;;
esac esac
model="$_"
model=$_
;; ;;
"BSD" | "MINIX") BSD|MINIX)
model="$(sysctl -n hw.vendor hw.product)" model=$(sysctl -n hw.vendor hw.product)
;; ;;
"Windows") Windows)
model="$(wmic computersystem get manufacturer,model)" model=$(wmic computersystem get manufacturer,model)
model="${model/Manufacturer}" model=${model/Manufacturer}
model="${model/Model}" model=${model/Model}
;; ;;
"Solaris") Solaris)
model="$(prtconf -b | awk -F':' '/banner-name/ {printf $2}')" model=$(prtconf -b | awk -F':' '/banner-name/ {printf $2}')
;; ;;
"AIX") AIX)
model="$(/usr/bin/uname -M)" model=$(/usr/bin/uname -M)
;; ;;
"FreeMiNT") FreeMiNT)
model="$(sysctl -n hw.model)" model=$(sysctl -n hw.model)
;; ;;
esac esac
# Remove dummy OEM info. # Remove dummy OEM info.
model="${model//To be filled by O.E.M.}" model=${model//To be filled by O.E.M.}
model="${model//To Be Filled*}" model=${model//To Be Filled*}
model="${model//OEM*}" model=${model//OEM*}
model="${model//Not Applicable}" model=${model//Not Applicable}
model="${model//System Product Name}" model=${model//System Product Name}
model="${model//System Version}" model=${model//System Version}
model="${model//Undefined}" model=${model//Undefined}
model="${model//Default string}" model=${model//Default string}
model="${model//Not Specified}" model=${model//Not Specified}
model="${model//Type1ProductConfigId}" model=${model//Type1ProductConfigId}
model="${model//INVALID}" model=${model//INVALID}
model="${model//<2F>}" model=${model//<2F>}
case "$model" in case $model in
"Standard PC"*) model="KVM/QEMU (${model})" ;; "Standard PC"*) model="KVM/QEMU (${model})" ;;
"OpenBSD"*) model="vmm ($model)" ;; "OpenBSD"*) model="vmm ($model)" ;;
esac esac
} }
get_title() { get_title() {
user="${USER:-$(whoami || printf "%s" "${HOME/*\/}")}" user=${USER:-$(id -un || printf %s "${HOME/*\/}")}
hostname="${HOSTNAME:-$(hostname)}" hostname=${HOSTNAME:-$(hostname)}
title="${title_color}${bold}${user}${at_color}@${title_color}${bold}${hostname}" title=${title_color}${bold}${user}${at_color}@${title_color}${bold}${hostname}
length="$((${#user} + ${#hostname} + 1))" length=$((${#user} + ${#hostname} + 1))
} }
get_kernel() { get_kernel() {
# Since these OS are integrated systems, it's better to skip this function altogether # Since these OS are integrated systems, it's better to skip this function altogether
[[ "$os" =~ (AIX|IRIX) ]] && return [[ $os =~ (AIX|IRIX) ]] && return
# Haiku uses 'uname -v' and not - 'uname -r'. # Haiku uses 'uname -v' and not - 'uname -r'.
[[ "$os" == Haiku ]] && { [[ $os == Haiku ]] && {
kernel=$(uname -v) kernel=$(uname -v)
return return
} }
case "$kernel_shorthand" in case $kernel_shorthand in
"on") kernel="$kernel_version" ;; on) kernel=$kernel_version ;;
"off") kernel="$kernel_name $kernel_version" ;; off) kernel="$kernel_name $kernel_version" ;;
esac esac
# Hide kernel info if it's identical to the distro info. # Hide kernel info if it's identical to the distro info.
if [[ "$os" =~ (BSD|MINIX) && "$distro" == *"$kernel_name"* ]]; then [[ $os =~ (BSD|MINIX) && $distro == *"$kernel_name"* ]] &&
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") kernel="$kernel_version" ;; on|tiny) kernel=$kernel_version ;;
*) unset kernel ;; *) unset kernel ;;
esac esac
fi
} }
get_uptime() { get_uptime() {
# Get uptime in seconds. # Get uptime in seconds.
case "$os" in case $os in
"Linux" | "Windows" | "MINIX") Linux|Windows|MINIX)
if [[ -r /proc/uptime ]]; then if [[ -r /proc/uptime ]]; then
seconds="$(< /proc/uptime)" s=$(< /proc/uptime)
seconds="${seconds/.*}" s=${s/.*}
else else
boot="$(date -d"$(uptime -s)" +%s)" boot=$(date -d"$(uptime -s)" +%s)
now="$(date +%s)" now=$(date +%s)
seconds="$((now - boot))" s=$((now - boot))
fi fi
;; ;;
"Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT") "Mac OS X"|"iPhone OS"|BSD|FreeMiNT)
boot="$(sysctl -n kern.boottime)" boot=$(sysctl -n kern.boottime)
boot="${boot/\{ sec = }" boot=${boot/\{ sec = }
boot="${boot/,*}" boot=${boot/,*}
# Get current date in seconds. # Get current date in seconds.
now="$(date +%s)" now=$(date +%s)
seconds="$((now - boot))" s=$((now - boot))
;; ;;
"Solaris") Solaris)
seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')" s=$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')
seconds="${seconds/.*}" s=${s/.*}
;; ;;
"AIX" | "IRIX") AIX|IRIX)
t="$(LC_ALL=POSIX ps -o etime= -p 1)" t=$(LC_ALL=POSIX ps -o etime= -p 1)
d="0" h="0"
case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac [[ $t == *-* ]] && { d=${t%%-*}; t=${t#*-}; }
case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac [[ $t == *:*:* ]] && { h=${t%%:*}; t=${t#*:}; }
h="${h#0}" t="${t#0}"
seconds="$((d*86400 + h*3600 + ${t%%:*}*60 + ${t#*:}))" h=${h#0}
t=${t#0}
s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))
;; ;;
"Haiku") Haiku)
seconds=$(($(system_time) / 1000000)) s=$(($(system_time) / 1000000))
;; ;;
esac esac
days="$((seconds / 60 / 60 / 24)) days" d="$((s / 60 / 60 / 24)) days"
hours="$((seconds / 60 / 60 % 24)) hours" h="$((s / 60 / 60 % 24)) hours"
mins="$((seconds / 60 % 60)) minutes" m="$((s / 60 % 60)) mins"
# Remove plural if < 2. # Remove plural if < 2.
((${days/ *} == 1)) && days="${days/s}" ((${d/ *} == 1)) && d=${d/s}
((${hours/ *} == 1)) && hours="${hours/s}" ((${h/ *} == 1)) && h=${h/s}
((${mins/ *} == 1)) && mins="${mins/s}" ((${m/ *} == 1)) && m=${m/s}
# Hide empty fields. # Hide empty fields.
((${days/ *} == 0)) && unset days ((${d/ *} == 0)) && unset days
((${hours/ *} == 0)) && unset hours ((${h/ *} == 0)) && unset hours
((${mins/ *} == 0)) && unset mins ((${m/ *} == 0)) && unset mins
uptime="${days:+$days, }${hours:+$hours, }${mins}" uptime=${d:+$d, }${h:+$h, }$m
uptime="${uptime%', '}" uptime=${uptime%', '}
uptime="${uptime:-${seconds} seconds}" uptime=${uptime:-$seconds secs}
# Make the output of uptime smaller. # Make the output of uptime smaller.
case "$uptime_shorthand" in case $uptime_shorthand in
"on") on) ;;
uptime="${uptime/minutes/mins}"
uptime="${uptime/minute/min}"
uptime="${uptime/seconds/secs}"
;;
"tiny") tiny)
uptime="${uptime/ days/d}" uptime=${uptime/ days/d}
uptime="${uptime/ day/d}" uptime=${uptime/ day/d}
uptime="${uptime/ hours/h}" uptime=${uptime/ hours/h}
uptime="${uptime/ hour/h}" uptime=${uptime/ hour/h}
uptime="${uptime/ minutes/m}" uptime=${uptime/ mins/m}
uptime="${uptime/ minute/m}" uptime=${uptime/ min/m}
uptime="${uptime/ seconds/s}" uptime=${uptime/ secs/s}
uptime="${uptime//,}" uptime=${uptime//,}
;; ;;
esac esac
} }