From f8f50f6b1d0734438efe8357309a6c4f883b1614 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 22:43:22 +1100 Subject: [PATCH 1/6] Distro: [Linux] Source /etc/*ease files --- neofetch | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/neofetch b/neofetch index 5c1a8277..0c454c16 100755 --- a/neofetch +++ b/neofetch @@ -160,26 +160,21 @@ getdistro() { distro="Android $(getprop ro.build.version.release)" else - # Workarounds are included in every shorthand option + + # Source the os-release file + for file in /etc/*ease /usr/lib/*ease; do + source "$file" 2>/dev/null + done + case "$distro_shorthand" in - "on") - distro="$(awk -F'=' '/^NAME|VERSION_ID=/ {print $2; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_ID|DISTRIB_RELEASE=/ {print $2}' /etc/openwrt_release)" - ;; - - "tiny") - distro="$(awk -F'=' '/^NAME=/ {print $2; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '/^TAILS_PRODUCT_NAME=/ {print $2}' /etc/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_ID=/ {print $2}' /etc/openwrt_release)" - ;; - - *) - distro="$(awk -F'=' '/^PRETTY_NAME=/ {print $2; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease)" - [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_DESCRIPTION=/ {print $2}' /etc/openwrt_release)" - ;; + "on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; + "tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;; + "off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; esac + + # Workarounds for distros that go against the os-release standard. + [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" + [ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease)" fi distro="${distro//\"}" distro="${distro//\'}" From d45002ca15f0d6165adee68ed0626f6a128f6fc1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 22:47:27 +1100 Subject: [PATCH 2/6] Distro: [Linux] Also look in /usr/lib/*ease --- neofetch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 0c454c16..a9788c08 100755 --- a/neofetch +++ b/neofetch @@ -168,13 +168,13 @@ getdistro() { case "$distro_shorthand" in "on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; - "tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;; + "tiny") distro="${NAME:-${DISTRIB_ID:-"${TAILS_PRODUCT_NAME}"}}" ;; "off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; esac # Workarounds for distros that go against the os-release standard. - [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease)" + [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" + [ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" fi distro="${distro//\"}" distro="${distro//\'}" From 29ccbb2a31b19fee861cab4980f7d1bc21f439e0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 23:00:14 +1100 Subject: [PATCH 3/6] Remove stray line --- neofetch | 1 - 1 file changed, 1 deletion(-) diff --git a/neofetch b/neofetch index a9788c08..34d5ec04 100755 --- a/neofetch +++ b/neofetch @@ -160,7 +160,6 @@ getdistro() { distro="Android $(getprop ro.build.version.release)" else - # Source the os-release file for file in /etc/*ease /usr/lib/*ease; do source "$file" 2>/dev/null From b1b6226189f9d27d751e330a15449154602147be Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 23:05:30 +1100 Subject: [PATCH 4/6] Distro: [Linux] Fix fallbacks not working --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 34d5ec04..e97a7296 100755 --- a/neofetch +++ b/neofetch @@ -172,8 +172,8 @@ getdistro() { esac # Workarounds for distros that go against the os-release standard. - [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" + [ -z "$(trim $distro")" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" + [ -z "$(trim $distro")" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" fi distro="${distro//\"}" distro="${distro//\'}" From dcdf6190c8f7cbd87538805f85a94d51ef2af8b0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 23:09:21 +1100 Subject: [PATCH 5/6] Distro: [Linux] Fix incorrect quoting --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index e97a7296..de657a3c 100755 --- a/neofetch +++ b/neofetch @@ -172,8 +172,8 @@ getdistro() { esac # Workarounds for distros that go against the os-release standard. - [ -z "$(trim $distro")" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$(trim $distro")" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" + [ -z "$(trim "$distro")" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" + [ -z "$(trim "$distro")" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" fi distro="${distro//\"}" distro="${distro//\'}" From e0fff44cce3719c5ffe82064a3d96b5d483e6138 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Nov 2016 23:23:11 +1100 Subject: [PATCH 6/6] Distro: [Linux] Fallback only print first line --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index de657a3c..882394db 100755 --- a/neofetch +++ b/neofetch @@ -173,7 +173,7 @@ getdistro() { # Workarounds for distros that go against the os-release standard. [ -z "$(trim "$distro")" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)" - [ -z "$(trim "$distro")" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease /usr/lib/*ease)" + [ -z "$(trim "$distro")" ] && distro="$(awk -F'=' '{print $2; exit}' /etc/*ease /usr/lib/*ease)" fi distro="${distro//\"}" distro="${distro//\'}"