Ascii: Cleanup ascii functions

This commit is contained in:
Dylan Araps 2016-11-13 20:21:32 +11:00
parent d504691c46
commit 5511b04940
1 changed files with 63 additions and 58 deletions

119
neofetch
View File

@ -19,6 +19,9 @@ export LANG=C
# Set no case match. # Set no case match.
shopt -s nocasematch shopt -s nocasematch
# Reset colors/bold
reset="\033[0m"
# DETECT INFORMATION # DETECT INFORMATION
get_os() { get_os() {
@ -2367,196 +2370,198 @@ get_underline() {
fi fi
} }
colors() { get_distro_colors() {
# Reset colors/bold # This function sets the text colors according
reset="\033[0m" # to your OS/Distro's logo colors.
#
# Change color of logo based on distro # $ascii_distro is the same as $distro
case "$ascii_distro" in case "$ascii_distro" in
"Arch"* | "Antergos"*) "Arch"*)
setcolors 6 4 set_colors 4 7
;;
"Antergos"*)
set_colors 6 4
;; ;;
"BlankOn"* | "DracOS"*) "BlankOn"* | "DracOS"*)
setcolors 1 7 set_colors 1 7
;; ;;
"CentOS"*) "CentOS"*)
setcolors 3 2 4 5 7 set_colors 3 2 4 5 7
;; ;;
"CRUX"* | "Chakra"* | "gNewSense"* | "SailfishOS"* | "Alpine"* | "Ubuntu-GNOME"* | "Qubes"*) "CRUX"* | "Chakra"* | "gNewSense"* | "SailfishOS"* | "Alpine"* | "Ubuntu-GNOME"* | "Qubes"*)
setcolors 4 5 7 6 set_colors 4 5 7 6
;; ;;
"Chrom"*) "Chrom"*)
setcolors 2 1 3 4 7 set_colors 2 1 3 4 7
ascii_distro="chrome" ascii_distro="chrome"
;; ;;
"Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"*) "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"*)
setcolors 1 7 3 set_colors 1 7 3
;;
"Red Star"* | "Redstar")
setcolors 1 7 3
ascii_distro="redstar"
;; ;;
"FreeBSD"* | "PCBSD"*) "FreeBSD"* | "PCBSD"*)
setcolors 1 7 3 set_colors 1 7 3
ascii_distro="freebsd" ascii_distro="freebsd"
;; ;;
"Red Star"* | "Redstar")
set_colors 1 7 3
ascii_distro="redstar"
;;
"Red"*) "Red"*)
setcolors 1 7 3 set_colors 1 7 3
ascii_distro="redhat" ascii_distro="redhat"
;; ;;
"Pardus"*) "Pardus"*)
setcolors 3 7 set_colors 3 7
;; ;;
"Kogaion"* | "Elementary"* | "GalliumOS"* | "Rosa"* | "OpenWrt"* | "Netrunner"*) "Kogaion"* | "Elementary"* | "GalliumOS"* | "Rosa"* | "OpenWrt"* | "Netrunner"*)
setcolors 4 7 set_colors 4 7
;; ;;
"Fedora"* | "Korora"* | "Sabayon"* | "Frugalware"* | "Exherbo"*) "Fedora"* | "Korora"* | "Sabayon"* | "Frugalware"* | "Exherbo"*)
setcolors 4 7 1 set_colors 4 7 1
;; ;;
"Gentoo"* | "Funtoo"* | "SteamOS"* | "Devuan"*) "Gentoo"* | "Funtoo"* | "SteamOS"* | "Devuan"*)
setcolors 5 7 set_colors 5 7
;; ;;
"KDE"*) "KDE"*)
setcolors 2 7 set_colors 2 7
ascii_distro="kde" ascii_distro="kde"
;; ;;
"Kali"*) "Kali"*)
setcolors 4 8 set_colors 4 8
;; ;;
"BunsenLabs"*) "BunsenLabs"*)
setcolors 8 7 set_colors 8 7
;; ;;
*"OS X"* | *"iOS"* | "Mac" | *"macOS"*) *"OS X"* | *"iOS"* | "Mac" | *"macOS"*)
setcolors 2 3 1 1 5 4 set_colors 2 3 1 1 5 4
ascii_distro="mac" ascii_distro="mac"
;; ;;
"OpenMandriva"*) "OpenMandriva"*)
setcolors 4 3 set_colors 4 3
;; ;;
"Mageia"* | "Porteus"*) "Mageia"* | "Porteus"*)
setcolors 6 7 set_colors 6 7
;; ;;
"Peppermint"*) "Peppermint"*)
setcolors 1 7 set_colors 1 7
;; ;;
*"Mint"*) *"Mint"*)
setcolors 2 7 set_colors 2 7
ascii_distro="mint" ascii_distro="mint"
;; ;;
"LMDE"* | "Chapeau"* | "Bitrig"*) "LMDE"* | "Chapeau"* | "Bitrig"*)
setcolors 2 7 set_colors 2 7
;; ;;
"Android"*) "Android"*)
setcolors 2 7 set_colors 2 7
ascii_length_force="19" ascii_length_force="19"
;; ;;
"NetBSD"* | "Parabola"* | "Tails"* | "BLAG"*) "NetBSD"* | "Parabola"* | "Tails"* | "BLAG"*)
setcolors 5 7 set_colors 5 7
;; ;;
"OpenBSD"* | "GuixSD"*) "OpenBSD"* | "GuixSD"*)
setcolors 3 7 6 1 8 set_colors 3 7 6 1 8
;; ;;
*"SUSE"* | "Manjaro"* | "Deepin"*) *"SUSE"* | "Manjaro"* | "Deepin"*)
setcolors 2 7 set_colors 2 7
;; ;;
"PCLinuxOS"* | "Slackware"* | "KaOS"* | "Kubuntu"* | "Lubuntu"* | "Xubuntu"* | "OpenIndiana"*) "PCLinuxOS"* | "Slackware"* | "KaOS"* | "Kubuntu"* | "Lubuntu"* | "Xubuntu"* | "OpenIndiana"*)
setcolors 4 7 1 set_colors 4 7 1
;; ;;
"Puppy"* | "Quirky Werewolf"* | "Precise Puppy"*) "Puppy"* | "Quirky Werewolf"* | "Precise Puppy"*)
setcolors 4 7 set_colors 4 7
ascii_distro="puppy" ascii_distro="puppy"
;; ;;
"Sparky"*) "Sparky"*)
setcolors 1 7 set_colors 1 7
ascii_distro="sparky" ascii_distro="sparky"
;; ;;
"Scientific"*) "Scientific"*)
setcolors 4 1 7 set_colors 4 1 7
;; ;;
"Solus"*) "Solus"*)
setcolors 4 7 set_colors 4 7
;; ;;
"Trisquel"* | "NixOS"* | "Zorin"*) "Trisquel"* | "NixOS"* | "Zorin"*)
setcolors 4 6 set_colors 4 6
;; ;;
"Travis") "Travis")
setcolors 1 2 3 4 5 6 set_colors 1 2 3 4 5 6
;; ;;
"void"*) "void"*)
setcolors 2 8 set_colors 2 8
;; ;;
"Windows 8"* | "Windows 10"*) "Windows 8"* | "Windows 10"*)
setcolors 6 7 set_colors 6 7
ascii_distro="windows10" ascii_distro="windows10"
;; ;;
"Windows"*) "Windows"*)
setcolors 1 2 4 3 set_colors 1 2 4 3
;; ;;
"Haiku"*) "Haiku"*)
setcolors 2 0 set_colors 2 0
;; ;;
"Raspbian"*) "Raspbian"*)
setcolors 2 1 set_colors 2 1
;; ;;
"Linux") "Linux")
setcolors fg 8 3 set_colors fg 8 3
;; ;;
*) *)
case "$os" in if [[ "$os" == "Linux" ]]; then
"Linux")
ascii_distro="linux" ascii_distro="linux"
setcolors fg 8 3 set_colors fg 8 3
;; fi
esac
;; ;;
esac esac
# Overwrite distro colors if '$ascii_colors' doesn't # Overwrite distro colors if '$ascii_colors' doesn't
# equal 'distro'. # equal 'distro'.
[[ "${ascii_colors[0]}" != "distro" ]] && \ [[ "${ascii_colors[0]}" != "distro" ]] && \
setcolors ${ascii_colors[@]} set_colors ${ascii_colors[@]}
} }
setcolors() { set_colors() {
c1="$(color "$1")${ascii_bold}" c1="$(color "$1")${ascii_bold}"
c2="$(color "$2")${ascii_bold}" c2="$(color "$2")${ascii_bold}"
c3="$(color "$3")${ascii_bold}" c3="$(color "$3")${ascii_bold}"
@ -3153,7 +3158,7 @@ main() {
get_args "$@" get_args "$@"
get_distro get_distro
bold bold
colors get_distro_colors
# 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