General: Cleanup info()
This commit is contained in:
parent
39ef9207c1
commit
ba0c7e441f
29
neofetch
29
neofetch
|
@ -2385,23 +2385,19 @@ info() {
|
||||||
subtitle="$1"
|
subtitle="$1"
|
||||||
|
|
||||||
# Call the function and update variable
|
# Call the function and update variable
|
||||||
if [ -z "$2" ]; then
|
"get${2:-$1}" 2>/dev/null
|
||||||
"get$1" 2>/dev/null
|
eval output="\$${2:-$1}"
|
||||||
eval output="\$${1}"
|
|
||||||
|
|
||||||
else
|
|
||||||
"get$2" 2>/dev/null
|
|
||||||
eval output="\$${2}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Trim whitespace
|
# Trim whitespace
|
||||||
output="$(trim "$output")"
|
output="$(trim "$output")"
|
||||||
|
|
||||||
# If the output is empty, don't print anything
|
# If prin was used in the function, stop here.
|
||||||
if [ -z "$output" ]; then
|
[ "$prin" ] && \
|
||||||
err "Info: Couldn't detect $subtitle"
|
unset prin && return
|
||||||
return
|
|
||||||
fi
|
# If the output is empty, don't print anything.
|
||||||
|
[ -z "$output" ] && \
|
||||||
|
err "Info: Couldn't detect $subtitle" && return
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
title)
|
title)
|
||||||
|
@ -2410,9 +2406,7 @@ info() {
|
||||||
length="${#output}"
|
length="${#output}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
underline)
|
underline) string="${underline_color}${output}" ;;
|
||||||
string="${underline_color}${output}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
*)
|
||||||
string="${subtitle_color}${bold}${subtitle}${reset}"
|
string="${subtitle_color}${bold}${subtitle}${reset}"
|
||||||
|
@ -2469,6 +2463,9 @@ prin() {
|
||||||
padding_num="${padding/\\033\[}"
|
padding_num="${padding/\\033\[}"
|
||||||
string="$(printf "%.$((columns - ${padding_num/C} - gap))s" "$string")"
|
string="$(printf "%.$((columns - ${padding_num/C} - gap))s" "$string")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Tell info() that prin() was used.
|
||||||
|
prin=1
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
Reference in New Issue