Remove all 'Unknown' printing when a command fails, instead we display nothing

This commit is contained in:
Dylan 2016-03-26 23:36:37 +11:00
parent b4f19e8a3d
commit 912295d821
1 changed files with 5 additions and 43 deletions

View File

@ -511,10 +511,6 @@ case "$os" in
x64="64-bit" x64="64-bit"
x32="32-bit" x32="32-bit"
;; ;;
*)
distro="Unknown"
;;
esac esac
ascii_distro="$distro" ascii_distro="$distro"
@ -609,10 +605,6 @@ getuptime () {
uptime="up $uptime" uptime="up $uptime"
;; ;;
*)
uptime="Unknown"
;;
esac esac
# Make the output of uptime smaller. # Make the output of uptime smaller.
@ -732,8 +724,6 @@ getpackages () {
;; ;;
esac esac
packages=${packages// } packages=${packages// }
[ -z "$packages" ] && packages="Unknown"
} }
# }}} # }}}
@ -897,10 +887,6 @@ getcpu () {
speed=${speed:0:1}.${speed:1} speed=${speed:0:1}.${speed:1}
cpu="$cpu @ ${speed}GHz" cpu="$cpu @ ${speed}GHz"
;; ;;
*)
cpu="Unknown"
;;
esac esac
# Remove uneeded patterns from cpu output # Remove uneeded patterns from cpu output
@ -970,6 +956,7 @@ getgpu () {
# fallback to looking for a prefix of 'VGA' # fallback to looking for a prefix of 'VGA'
[ -z "$gpu" ] && \ [ -z "$gpu" ] && \
gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")"
gpu=${gpu//??':'??'.'?} gpu=${gpu//??':'??'.'?}
# Count the number of GPUs # Count the number of GPUs
@ -1166,10 +1153,6 @@ getmemory () {
memory="$((${memused%% *} / 1024))MB / " memory="$((${memused%% *} / 1024))MB / "
memory+="$((${memtotal%% *} / 1024))MB" memory+="$((${memtotal%% *} / 1024))MB"
;; ;;
*)
memory="Unknown"
;;
esac esac
# Progress bars # Progress bars
@ -1230,7 +1213,7 @@ getsong () {
state="$(osascript -e 'tell application "iTunes" to player state as string')" state="$(osascript -e 'tell application "iTunes" to player state as string')"
else else
song="Unknown" song="Not Playing"
fi fi
case "$state" in case "$state" in
@ -1302,10 +1285,6 @@ getresolution () {
[ ! -z "$width" ] && \ [ ! -z "$width" ] && \
resolution="${width}x${height}" resolution="${width}x${height}"
;; ;;
"*")
resolution="Unknown"
;;
esac esac
resolution=${resolution%,*} resolution=${resolution%,*}
@ -1515,9 +1494,8 @@ getdisk () {
"Mac OS X") df_flags="-H / -l" ;; "Mac OS X") df_flags="-H / -l" ;;
*"BSD") *"BSD")
case "$os" in case "$distro" in
"FreeBSD") df_flags="-h -c -l" ;; "FreeBSD"*) df_flags="-h -c -l" ;;
*) disk="Unknown"; return ;;
esac esac
;; ;;
esac esac
@ -1673,10 +1651,6 @@ getlocalip () {
"Windows") "Windows")
localip="$(ipconfig | awk -F ': ' '/IPv4 Address/ {printf $2}')" localip="$(ipconfig | awk -F ': ' '/IPv4 Address/ {printf $2}')"
;; ;;
*)
localip="Unknown"
;;
esac esac
} }
@ -1689,9 +1663,6 @@ getpublicip () {
elif type -p wget >/dev/null 2>&1; then elif type -p wget >/dev/null 2>&1; then
publicip="$(wget -qO- "$public_ip_host"; printf "%s")" publicip="$(wget -qO- "$public_ip_host"; printf "%s")"
else
publicip="Unknown"
fi fi
} }
@ -1751,10 +1722,6 @@ getbirthday () {
birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')" birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')"
birthday_shorthand="on" birthday_shorthand="on"
;; ;;
*)
birthday="Unknown"
;;
esac esac
;; ;;
@ -1762,11 +1729,6 @@ getbirthday () {
birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')"
date_cmd="$(date -d"$birthday" +"$birthday_format")" date_cmd="$(date -d"$birthday" +"$birthday_format")"
;; ;;
*)
birthday="Unknown"
;;
esac esac
# Strip seconds from time output # Strip seconds from time output