Move OS detection to a function and cleanup comments

This commit is contained in:
Dylan Araps 2016-08-13 21:28:23 +10:00
parent 256205aaea
commit 66749c58ab
1 changed files with 12 additions and 26 deletions

View File

@ -19,20 +19,20 @@ export LANG=C
# Set no case match. # Set no case match.
shopt -s nocasematch shopt -s nocasematch
# Gather Info {{{ # Gather Info {{{
# Operating System {{{ # Operating System {{{
case "$(uname)" in getos() {
"Linux") os="Linux" ;; case "$(uname)" in
"Darwin") os="$(sw_vers -productName)" ;; "Linux") os="Linux" ;;
*"BSD" | "DragonFly") os="BSD" ;; "Darwin") os="$(sw_vers -productName)" ;;
"CYGWIN"*) os="Windows" ;; *"BSD" | "DragonFly") os="BSD" ;;
"SunOS") os="Solaris" ;; "CYGWIN"*) os="Windows" ;;
*) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;; "SunOS") os="Solaris" ;;
esac *) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;;
esac
}
# }}} # }}}
@ -1764,10 +1764,8 @@ getcols() {
# }}} # }}}
# Images {{{ # Images {{{
# Wallpaper {{{ # Wallpaper {{{
getwallpaper() { getwallpaper() {
@ -2135,13 +2133,10 @@ getimagebackend() {
# }}} # }}}
# }}} # }}}
# Text Formatting {{{ # Text Formatting {{{
# Info {{{ # Info {{{
info() { info() {
@ -2512,13 +2507,10 @@ trim() {
# }}} # }}}
# }}} # }}}
# Other {{{ # Other {{{
# Error {{{ # Error {{{
err() { err() {
@ -2696,13 +2688,10 @@ dynamicprompt() {
# }}} # }}}
# }}} # }}}
# Usage {{{ # Usage {{{
usage() { cat << EOF usage() { cat << EOF
usage: neofetch --option "value" --option "value" usage: neofetch --option "value" --option "value"
@ -2834,13 +2823,10 @@ EOF
exit 1 exit 1
} }
# }}} # }}}
# Args {{{ # Args {{{
while [ "$1" ]; do while [ "$1" ]; do
case $1 in case $1 in
# Info # Info
@ -3026,13 +3012,13 @@ while [ "$1" ]; do
shift shift
done done
# }}} # }}}
# Call Functions and Finish Up {{{ # Call Functions and Finish Up {{{
main() { main() {
getos
# Restore cursor and clear screen on ctrl+c # Restore cursor and clear screen on ctrl+c
trap 'printf "\033[?25h"; clear; exit' 2 trap 'printf "\033[?25h"; clear; exit' 2