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