Move the commands near the bottom of the script to a function called main
This commit is contained in:
parent
2511511174
commit
7a774dd48d
39
neofetch
39
neofetch
|
@ -2532,14 +2532,11 @@ getdefaultconfig () {
|
|||
fi
|
||||
}
|
||||
|
||||
# Source config file
|
||||
getdefaultconfig 2>/dev/null
|
||||
|
||||
# }}}
|
||||
|
||||
# Source Config {{{
|
||||
|
||||
getconfig () {
|
||||
getuserconfig () {
|
||||
# Check $config_file
|
||||
if [ -f "$config_file" ]; then
|
||||
source "$config_file"
|
||||
|
@ -2579,7 +2576,9 @@ case "$@" in
|
|||
config="off"
|
||||
;;
|
||||
esac
|
||||
[ "${config:-on}" == "on" ] && getconfig 2>/dev/null
|
||||
|
||||
getdefaultconfig 2>/dev/null
|
||||
[ "${config:-on}" == "on" ] && getuserconfig 2>/dev/null
|
||||
|
||||
|
||||
# }}}
|
||||
|
@ -2925,7 +2924,7 @@ while [ "$1" ]; do
|
|||
--config)
|
||||
case "$2" in
|
||||
"none" | "off") config="off" ;;
|
||||
*) config_file="$2"; config="on"; getconfig 2>/dev/null ;;
|
||||
*) config_file="$2"; config="on"; getuserconfig 2>/dev/null ;;
|
||||
esac
|
||||
;;
|
||||
--test)
|
||||
|
@ -2973,9 +2972,13 @@ done
|
|||
|
||||
# Call Functions and Finish Up {{{
|
||||
|
||||
main () {
|
||||
# Restore cursor and clear screen on ctrl+c
|
||||
trap 'printf "\033[?25h"; clear; exit' 2
|
||||
|
||||
# If the script exits for any reason, unhide the cursor.
|
||||
trap 'printf "\033[?25h"' EXIT
|
||||
|
||||
# Distro detection
|
||||
getdistro
|
||||
case "${ascii_distro:-auto}" in
|
||||
|
@ -2986,17 +2989,17 @@ esac
|
|||
bold
|
||||
colors
|
||||
|
||||
# If the script exits for any reason, unhide the cursor.
|
||||
trap 'printf "\033[?25h"' EXIT
|
||||
|
||||
# Clear the scren
|
||||
clear
|
||||
|
||||
# Hide the cursor
|
||||
printf "\033[?25l"
|
||||
|
||||
# Images {{{
|
||||
|
||||
# Get the image src
|
||||
if [ "$image" != "off" ]; then
|
||||
# If iterm2 is detected use iterm2 backend.
|
||||
# Set the image backend
|
||||
if [ -n "$ITERM_PROFILE" ]; then
|
||||
image_backend="iterm2"
|
||||
|
||||
|
@ -3034,6 +3037,8 @@ if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# }}}
|
||||
|
||||
# Disable line wrap
|
||||
printf "\033[?7l"
|
||||
|
||||
|
@ -3066,13 +3071,15 @@ info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW C
|
|||
printf "%b%s" "\033[?7h"
|
||||
|
||||
# If enabled take a screenshot
|
||||
if [ "$scrot" == "on" ]; then
|
||||
takescrot
|
||||
fi
|
||||
[ "$scrot" == "on" ] && takescrot
|
||||
|
||||
# Show error messages
|
||||
if [ "$verbose" == "on" ]; then
|
||||
printf "%s" "$err"
|
||||
fi
|
||||
[ "$verbose" == "on" ] && printf "%s" "$err"
|
||||
|
||||
# Reset exit status of the tests above.
|
||||
printf "%s"
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
# }}}
|
||||
|
|
Reference in New Issue