浏览代码

Merge pull request #585 from dylanaraps/ascii_simp

Ascii: Simplify file handling.
Dylan Araps 8 年之前
父节点
当前提交
5eba7fc91e
共有 2 个文件被更改,包括 436 次插入102 次删除
  1. 0 6
      ascii/distro/travis
  2. 436 96
      neofetch

+ 0 - 6
ascii/distro/travis

@@ -1,6 +0,0 @@
-${c1} _______        _
-${c2}|__   __|      | |
-${c3}   | | ___  ___| |_
-${c4}   | |/ _ \/ __| __|
-${c5}   | |  __/\__ \ |_
-${c6}   |_|\___||___/\__|

+ 436 - 96
neofetch

@@ -1906,34 +1906,24 @@ get_ascii() {
         [[ "$ascii" != "distro" && ! -f "$ascii" ]] && \
         [[ "$ascii" != "distro" && ! -f "$ascii" ]] && \
             err "Ascii: Ascii file not found, using distro ascii."
             err "Ascii: Ascii file not found, using distro ascii."
 
 
-        # Lowercase the distro name so we can match it to a file.
-        if (("$bash_version" <= 3)); then
-            ascii="$(tr '[:upper:]' '[:lower:]' <<< "$ascii_distro")"
-        else
-            ascii="${ascii_distro,,}"
-        fi
-
-        if [[ -f "/usr/share/neofetch/ascii/distro/${ascii/ *}" ]]; then
-            ascii="/usr/share/neofetch/ascii/distro/${ascii/ *}"
+        if [[ -d "/usr/share/neofetch/ascii/distro" ]]; then
+            ascii_dir="/usr/share/neofetch/ascii/distro"
 
 
-        elif [[ -f "/usr/local/share/neofetch/ascii/distro/${ascii/ *}" ]]; then
-            ascii="/usr/local/share/neofetch/ascii/distro/${ascii/ *}"
+        elif [[ -d "/usr/local/share/neofetch/ascii/distro" ]]; then
+            ascii_dir="/usr/local/share/neofetch/ascii/distro"
 
 
-        elif [[ -f "/data/data/com.termux/files/usr/share/neofetch/ascii/distro/${ascii/ *}" ]]; then
-            ascii="/data/data/com.termux/files/usr/share/neofetch/ascii/distro/${ascii/ *}"
+        elif [[ -d "/data/data/com.termux/files/usr/share/neofetch/ascii/distro" ]]; then
+            ascii_dir="/data/data/com.termux/files/usr/share/neofetch/ascii/distro"
 
 
         else
         else
             get_script_dir 2>/dev/null
             get_script_dir 2>/dev/null
+            ascii_dir="${script_dir}/ascii/distro"
 
 
-            # If the ascii file doesn't exist fallback to text mode.
-            if [[ -f "$script_dir/ascii/distro/${ascii/ *}" ]]; then
-                ascii="$script_dir/ascii/distro/${ascii/ *}"
-
-            else
-                to_off "Ascii: Ascii file not found, falling back to text mode."
-                return
-            fi
+            [[ -d "$ascii_dir" ]] || \
+                { to_off "Ascii: Ascii file not found, falling back to text mode."; return; }
         fi
         fi
+
+        ascii="${ascii_dir}/${ascii_file}"
     fi
     fi
 
 
     # Set locale to get correct padding.
     # Set locale to get correct padding.
@@ -2500,192 +2490,542 @@ get_distro_colors() {
     #
     #
     # $ascii_distro is the same as $distro.
     # $ascii_distro is the same as $distro.
     case "$ascii_distro" in
     case "$ascii_distro" in
-        "Arch"* | "Kogaion"* | "Elementary"* | "GalliumOS"* | "Rosa"* | "OpenWrt"* | "Netrunner"* | "PCLinuxOS"* | "Slackware"* | "KaOS"* | "Kubuntu"* | "Lubuntu"* | "Xubuntu"* | "OpenIndiana"* | "Fedora"* | "Korora"* | "Sabayon"* | "Frugalware"* | "Exherbo"* | "Scientific"* | "Solus"* | "ChaletOS"* | "Apricity"* | "SwagArch"* | "AOSC"* | "Ubuntu-Budgie"*)
+        "Alpine"*)
+            set_colors 4 5 7 6
+            ascii_file="alpine"
+        ;;
+
+        "Android"*)
+            set_colors 2 7
+            ascii_file="android"
+            ascii_length_force="19"
+        ;;
+
+        "Antergos"*)
+            set_colors 4 6
+            ascii_file="antergos"
+        ;;
+
+        "antiX"*)
+            set_colors 1 7 3
+            ascii_file="antix"
+        ;;
+
+        "AOSC"*)
             set_colors 4 7 1
             set_colors 4 7 1
+            ascii_file="aosc"
         ;;
         ;;
 
 
-        "RFRemix"*)
+        "Apricity"*)
             set_colors 4 7 1
             set_colors 4 7 1
-            ascii_distro="Fedora"
+            ascii_file="apricity"
+        ;;
+
+        "arch_small")
+            set_colors 4 7 1
+            ascii_file="arch_small"
+        ;;
+
+        "arch_old")
+            set_colors 4 7 1
+            ascii_file="arch_old"
+        ;;
+
+        "Arch"*)
+            set_colors 4 7 1
+            ascii_file="arch"
+        ;;
+
+        "Bitrig"*)
+            set_colors 2 7
+            ascii_file="bitrig"
+        ;;
+
+        "BLAG"*)
+            set_colors 5 7
+            ascii_file="blag"
+        ;;
+
+        "BlankOn"*)
+            set_colors 1 7 3
+            ascii_file="blankon"
+        ;;
+
+       "BSD")
+            set_colors 1 7 4 3 6
+            ascii_file="bsd"
+        ;;
+
+        "BunsenLabs"*)
+            set_colors fg 7
+            ascii_file="bunsenlabs"
         ;;
         ;;
 
 
         "CentOS"*)
         "CentOS"*)
             set_colors 3 2 4 5 7
             set_colors 3 2 4 5 7
+            ascii_file="centos"
         ;;
         ;;
 
 
-        "GoboLinux"*)
-            set_colors 5 4 6 2
+        "Chakra"*)
+            set_colors 4 5 7 6
+            ascii_file="chakra"
         ;;
         ;;
 
 
-        "SalentOS"*)
-            set_colors 2 1 3 7
+        "ChaletOS"*)
+            set_colors 4 7 1
+            ascii_file="chaletos"
         ;;
         ;;
 
 
-        "CRUX"* | "Chakra"* | "gNewSense"* | "SailfishOS"* | "Alpine"* | "Ubuntu-GNOME"* | "Qubes"*)
-            set_colors 4 5 7 6
+        "Chapeau"*)
+            set_colors 2 7
+            ascii_file="chapeau"
         ;;
         ;;
 
 
         "Chrom"*)
         "Chrom"*)
             set_colors 2 1 3 4 7
             set_colors 2 1 3 4 7
-            ascii_distro="chrome"
+            ascii_file="chrome"
         ;;
         ;;
 
 
-        "Raspbian"*)
-            set_colors 2 1
+        "crux_small")
+            set_colors 4 5 7 6
+            ascii_file="crux_small"
         ;;
         ;;
 
 
-        "Debian"* | "Ubuntu"* | "DragonFly"* | "PacBSD"* | "Oracle"* | "BlankOn"* | "DracOS"* | "Peppermint"* | "Minix"*)
-            set_colors 1 7 3
+        "CRUX"*)
+            set_colors 4 5 7 6
+            ascii_file="crux"
         ;;
         ;;
 
 
-        "antiX"*)
+        "Debian"*)
             set_colors 1 7 3
             set_colors 1 7 3
-            ascii_distro="antix"
+            ascii_file="debian"
         ;;
         ;;
 
 
-        "FreeBSD"*)
-            set_colors 1 7 3
-            ascii_distro="freebsd"
+        "Deepin"*)
+            set_colors 2 7
+            ascii_file="deepin"
         ;;
         ;;
 
 
-        "PCBSD"* | "TrueOS"*)
+        "Devuan"*)
+            set_colors 5 7
+            ascii_file="devuan"
+        ;;
+
+        "DracOS"*)
             set_colors 1 7 3
             set_colors 1 7 3
-            ascii_distro="trueos"
+            ascii_file="dracos"
         ;;
         ;;
 
 
-        "Red Star"* | "Redstar")
+        "DragonFly"*)
             set_colors 1 7 3
             set_colors 1 7 3
-            ascii_distro="redstar"
+            ascii_file="dragonflybsd"
+        ;;
+
+        "Elementary"*)
+            set_colors 4 7 1
+            ascii_file="elementary"
+        ;;
+
+        "Exherbo"*)
+            set_colors 4 7 1
+            ascii_file="exherbo"
         ;;
         ;;
 
 
-        "Red"*)
+        "Fedora"* | "RFRemix"*)
+            set_colors 4 7 1
+            ascii_file="fedora"
+        ;;
+
+        "FreeBSD"*)
             set_colors 1 7 3
             set_colors 1 7 3
-            ascii_distro="redhat"
+            ascii_file="freebsd"
         ;;
         ;;
 
 
-        "Kali"*)
-            set_colors 4 8
+        "Frugalware"*)
+            set_colors 4 7 1
+            ascii_file="frugalware"
         ;;
         ;;
 
 
-        "BunsenLabs"*)
-            set_colors fg 7
+        "Funtoo"*)
+            set_colors 5 7
+            ascii_file="funtoo"
         ;;
         ;;
 
 
-        "OpenMandriva"*)
-            set_colors 4 3
+        "GalliumOS"*)
+            set_colors 4 7 1
+            ascii_file="galliumos"
         ;;
         ;;
 
 
-        "NetBSD"* | "Parabola"* | "Tails"* | "BLAG"* | "Funtoo"* | "SteamOS"* | "Devuan"*)
+        "gentoo_small")
             set_colors 5 7
             set_colors 5 7
+            ascii_file="gentoo_small"
         ;;
         ;;
 
 
         "Gentoo"*)
         "Gentoo"*)
             set_colors 5 7
             set_colors 5 7
-            ascii_distro="gentoo"
+            ascii_file="gentoo"
         ;;
         ;;
 
 
-        "OpenBSD"* | "GuixSD"* | "Pardus"*)
+        "gNewSense"*)
+            set_colors 4 5 7 6
+            ascii_file="gnewsense"
+        ;;
+
+        "GNU")
+            set_colors fg 7
+            ascii_file="gnu"
+        ;;
+
+        "GoboLinux"*)
+            set_colors 5 4 6 2
+            ascii_file="gobolinux"
+        ;;
+
+        "Grombyang"*)
+            set_colors 4 2 1
+            ascii_file="grombyang"
+        ;;
+
+        "GuixSD"*)
             set_colors 3 7 6 1 8
             set_colors 3 7 6 1 8
+            ascii_file="guixsd"
         ;;
         ;;
 
 
-        "Manjaro"* | "Deepin"* | "LMDE"* | "Chapeau"* | "Bitrig"*)
-            set_colors 2 7
+        "Haiku"*)
+            set_colors 2 8
+            ascii_file="haiku"
         ;;
         ;;
 
 
-        *"SUSE"*)
-            set_colors 2 7
-            ascii_distro="suse"
+        "Kali"*)
+            set_colors 4 8
+            ascii_file="kali"
+        ;;
+
+        "KaOS"*)
+            set_colors 4 7 1
+            ascii_file="kaos"
         ;;
         ;;
 
 
         "KDE"*)
         "KDE"*)
             set_colors 2 7
             set_colors 2 7
-            ascii_distro="kde"
+            ascii_file="kde"
         ;;
         ;;
 
 
-        "Android"*)
+        "Kogaion"*)
+            set_colors 4 7 1
+            ascii_file="kogaion"
+        ;;
+
+        "Korora"*)
+            set_colors 4 7 1
+            ascii_file="korora"
+        ;;
+
+        "Kubuntu"*)
+            set_colors 4 7 1
+            ascii_file="kubuntu"
+        ;;
+
+        "Linux")
+            set_colors fg 8 3
+            ascii_file="linux"
+        ;;
+
+        "LMDE"*)
             set_colors 2 7
             set_colors 2 7
-            ascii_length_force="19"
+            ascii_file="lmde"
+        ;;
+
+        "Lubuntu"*)
+            set_colors 4 7 1
+            ascii_file="lubuntu"
+        ;;
+
+        "mac" | "Darwin")
+            set_colors 2 3 1 1 5 4
+            ascii_file="mac"
+        ;;
+
+        "Mageia"*)
+            set_colors 6 7
+            ascii_file="mageia"
+        ;;
+
+        "Manjaro"*)
+            set_colors 2 7
+            ascii_file="manjaro"
+        ;;
+
+        "Minix"*)
+            set_colors 1 7 3
+            ascii_file="minix"
         ;;
         ;;
 
 
-        *"Mint"*)
+        "Linux Mint"* | "LinuxMint"*)
             set_colors 2 7
             set_colors 2 7
-            ascii_distro="mint"
+            ascii_file="mint"
+        ;;
+
+        "MX"*)
+            set_colors 4 6 7
+            ascii_file="mx"
+        ;;
+
+        "NetBSD"*)
+            set_colors 5 7
+            ascii_file="netbsd"
+        ;;
+
+        "Netrunner"*)
+            set_colors 4 7 1
+            ascii_file="netrunner"
+        ;;
+
+        "NixOS"*)
+            set_colors 4 6
+            ascii_file="nixos"
+        ;;
+
+        "openbsd_small")
+            set_colors 3 7 6 1 8
+            ascii_file="openbsd_small"
+        ;;
+
+        "OpenBSD"*)
+            set_colors 3 7 6 1 8
+            ascii_file="openbsd"
+        ;;
+
+        "OpenIndiana"*)
+            set_colors 4 7 1
+            ascii_file="openindiana"
+        ;;
+
+        "OpenMandriva"*)
+            set_colors 4 3
+            ascii_file="openmandriva"
+        ;;
+
+        "OpenWrt"*)
+            set_colors 4 7 1
+            ascii_file="openwrt"
+        ;;
+
+        "Oracle"*)
+            set_colors 1 7 3
+            ascii_file="oracle"
+        ;;
+
+        "PacBSD"*)
+            set_colors 1 7 3
+            ascii_file="pacbsd"
+        ;;
+
+        "Parabola"*)
+            set_colors 5 7
+            ascii_file="parabola"
+        ;;
+
+        "Pardus"*)
+            set_colors 3 7 6 1 8
+            ascii_file="pardus"
+        ;;
+
+        "Parrot"*)
+            set_colors 6 7
+            ascii_file="parrot"
+        ;;
+
+        "PCBSD"* | "TrueOS"*)
+            set_colors 1 7 3
+            ascii_file="trueos"
+        ;;
+
+        "PCLinuxOS"*)
+            set_colors 4 7 1
+            ascii_file="pclinuxos"
+        ;;
+
+        "Peppermint"*)
+            set_colors 1 7 3
+            ascii_file="peppermint"
+        ;;
+
+        "Porteus"*)
+            set_colors 6 7
+            ascii_file="porteus"
         ;;
         ;;
 
 
         "Puppy"* | "Quirky Werewolf"* | "Precise Puppy"*)
         "Puppy"* | "Quirky Werewolf"* | "Precise Puppy"*)
             set_colors 4 7
             set_colors 4 7
-            ascii_distro="puppy"
+            ascii_file="puppy"
+        ;;
+
+        "Qubes"*)
+            set_colors 4 5 7 6
+            ascii_file="qubes"
+        ;;
+
+        "Raspbian"*)
+            set_colors 2 1
+            ascii_file="raspbian"
+        ;;
+
+        "Red Star"* | "Redstar"*)
+            set_colors 1 7 3
+            ascii_file="redstar"
+        ;;
+
+        "Redhat"* | "Red Hat"* | "rhel"*)
+            set_colors 1 7 3
+            ascii_file="redhat"
+        ;;
+
+        "Rosa"*)
+            set_colors 4 7 1
+            ascii_file="rosa"
+        ;;
+
+        "Sabayon"*)
+            set_colors 4 7 1
+            ascii_file="sabayon"
+        ;;
+
+        "SailfishOS"*)
+            set_colors 4 5 7 6
+            ascii_file="sailfishos"
+        ;;
+
+        "SalentOS"*)
+            set_colors 2 1 3 7
+            ascii_file="salentos"
+        ;;
+
+        "Scientific"*)
+            set_colors 4 7 1
+            ascii_file="scientific"
+        ;;
+
+        "Slackware"*)
+            set_colors 4 7 1
+            ascii_file="slackware"
+        ;;
+
+        "SmartOS"*)
+            set_colors 6 7
+            ascii_file="smartos"
+        ;;
+
+        "Solus"*)
+            set_colors 4 7 1
+            ascii_file="solus"
         ;;
         ;;
 
 
         "Sparky"*)
         "Sparky"*)
             set_colors 1 7
             set_colors 1 7
-            ascii_distro="sparky"
+            ascii_file="sparky"
+        ;;
+
+        "SteamOS"*)
+            set_colors 5 7
+            ascii_file="steamos"
         ;;
         ;;
 
 
-        "Trisquel"* | "NixOS"* | "Zorin"* | "Antergos"*)
+        "SunOS" | "Solaris")
+            set_colors 3 7
+            ascii_file="solaris"
+        ;;
+
+        "openSUSE"* | "open SUSE"* | "SUSE"*)
+            set_colors 2 7
+            ascii_distro="suse"
+        ;;
+
+        "SwagArch"*)
+            set_colors 4 7 1
+            ascii_file="swagarch"
+        ;;
+
+        "Tails"*)
+            set_colors 5 7
+            ascii_file="tails"
+        ;;
+
+        "Trisquel"*)
             set_colors 4 6
             set_colors 4 6
+            ascii_file="trisquel"
         ;;
         ;;
 
 
-        "MX"*)
-            set_colors 4 6 7
-            ascii_distro="mx"
+        "Ubuntu-Budgie"*)
+            set_colors 4 7 1
+            ascii_file="ubuntu-budgie"
         ;;
         ;;
 
 
-        "Travis")
-            set_colors 1 2 3 4 5 6
+        "Ubuntu-GNOME"*)
+            set_colors 4 5 7 6
+            ascii_file="ubuntu-gnome"
         ;;
         ;;
 
 
-        "Grombyang"*)
-            set_colors 4 2 1
-            ascii_distro="grombyang"
+        "ubuntu_old")
+            set_colors 1 7 3
+            ascii_file="ubuntu_old"
         ;;
         ;;
 
 
-        "Void"* | "Haiku"*)
-            set_colors 2 8
+        "Ubuntu"*)
+            set_colors 1 7 3
+            ascii_file="ubuntu"
         ;;
         ;;
 
 
-        "Mageia"* | "Porteus"* | "Parrot"* | "SmartOS"*)
-            set_colors 6 7
+        "Void"*)
+            set_colors 2 8
+            ascii_file="void"
         ;;
         ;;
 
 
         "Windows 8"* | "Windows 10"*)
         "Windows 8"* | "Windows 10"*)
             set_colors 6 7
             set_colors 6 7
-            ascii_distro="windows10"
+            ascii_file="windows10"
         ;;
         ;;
 
 
         "Windows"*)
         "Windows"*)
             set_colors 1 2 4 3
             set_colors 1 2 4 3
+            ascii_file="windows"
         ;;
         ;;
 
 
-        "Linux")
-            set_colors fg 8 3
+        "Xubuntu"*)
+            set_colors 4 7 1
+            ascii_file="xubuntu"
         ;;
         ;;
 
 
-        *"OS X"* | *"iOS"* | "Mac" | *"macOS"*)
-            set_colors 2 3 1 1 5 4
-            ascii_distro="mac"
+        "Zorin"*)
+            set_colors 4 6
+            ascii_file="zorin"
         ;;
         ;;
 
 
         *)
         *)
             case "$kernel_name" in
             case "$kernel_name" in
-                "Linux")
-                    ascii_distro="linux"
-                    set_colors fg 8 3
-                ;;
-
                 *"BSD")
                 *"BSD")
-                    ascii_distro="bsd"
                     set_colors 1 7 4 3 6
                     set_colors 1 7 4 3 6
+                    ascii_file="bsd"
+                ;;
+
+                "Darwin")
+                    set_colors 2 3 1 1 5 4
+                    ascii_file="mac"
                 ;;
                 ;;
 
 
                 "GNU"*)
                 "GNU"*)
-                    ascii_distro="gnu"
-                    set_colors fg
+                    set_colors fg 7
+                    ascii_file="gnu"
+                ;;
+
+                "Linux")
+                    set_colors fg 8 3
+                    ascii_file="linux"
                 ;;
                 ;;
 
 
                 "SunOS")
                 "SunOS")
-                    ascii_distro="solaris"
-                    set_colors 3
+                    set_colors 3 7
+                    ascii_file="solaris"
                 ;;
                 ;;
             esac
             esac
         ;;
         ;;