From d1c3f30ba751e37b160ea74851d01446aef443ba Mon Sep 17 00:00:00 2001 From: dylan Date: Mon, 4 Apr 2016 21:18:17 +1000 Subject: [PATCH 01/11] Rewrite cpu function to fix issues with speeds lowe than 1ghz --- neofetch | 78 ++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/neofetch b/neofetch index a196861a..282fafb9 100755 --- a/neofetch +++ b/neofetch @@ -941,42 +941,12 @@ getwmtheme () { getcpu () { case "$os" in - "Linux") - # Get cpu name - cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)" - - # Get cpu speed - if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then - case "$speed_type" in - current) speed_type="scaling_cur_freq" ;; - min) speed_type="scaling_min_freq" ;; - max) speed_type="scaling_max_freq" ;; - bios) speed_type="bios_limit" ;; - scaling_current) speed_type="scaling_cur_freq" ;; - scaling_min) speed_type="scaling_min_freq" ;; - scaling_max) speed_type="scaling_max_freq" ;; - esac - - read -r speed < \ - /sys/devices/system/cpu/cpu0/cpufreq/${speed_type} - - speed=$((speed / 100000)) - else - speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) - speed=$((speed / 100)) - fi - speed=${speed:0:1}.${speed:1} - - cpu="$cpu @ ${speed}GHz" - cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) - ;; - "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" cores=$(sysctl -n hw.ncpu) ;; - *"BSD" | "Windows") + "Linux" | *"BSD" | "Windows") case "$distro" in "OpenBSD"* | "FreeBSD"*) # Get cpu name @@ -993,28 +963,46 @@ getcpu () { cores=$(sysctl -n hw.ncpu) ;; - "NetBSD"* | "Windows"*) + *) # Get cpu name - cpu="$(grep -F 'model name' /proc/cpuinfo)" - cpu=${cpu/model name*: } - cpu=${cpu/ @*} - cpu=${cpu// } - cpu=${cpu% } + cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)" # Get cpu speed - speed="$(grep -F 'cpu MHz' /proc/cpuinfo)" - speed=${speed/cpu MHz*: } - speed=${speed/\.} + if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then + case "$speed_type" in + current) speed_type="scaling_cur_freq" ;; + min) speed_type="scaling_min_freq" ;; + max) speed_type="scaling_max_freq" ;; + bios) speed_type="bios_limit" ;; + scaling_current) speed_type="scaling_cur_freq" ;; + scaling_min) speed_type="scaling_min_freq" ;; + scaling_max) speed_type="scaling_max_freq" ;; + esac + + read -r speed < \ + /sys/devices/system/cpu/cpu0/cpufreq/${speed_type} + + speed=$((speed / 100000)) + else + speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) + + case "$distro" in + "NetBSD"*) speed=$((speed / 10000)) ;; + *) speed=$((speed / 100)) ;; + esac + fi + + # Fix for speeds under 1ghz + if [ -z "${speed:1}" ]; then + speed="0.${speed}" + else + speed=${speed:0:1}.${speed:1} + fi - case "$distro" in - "NetBSD"*) speed=$((speed / 10000)) ;; - "Windows"*) speed=$((speed / 100000)) ;; - esac cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; esac - speed=${speed:0:1}.${speed:1} cpu="$cpu @ ${speed}GHz" ;; esac From 37e9ac5d0fa5174c5c0baeedd0f681e108cb8b2f Mon Sep 17 00:00:00 2001 From: dylan Date: Mon, 4 Apr 2016 21:25:42 +1000 Subject: [PATCH 02/11] Nove formatting bloc down --- neofetch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index 282fafb9..cf9747be 100755 --- a/neofetch +++ b/neofetch @@ -992,17 +992,17 @@ getcpu () { esac fi - # Fix for speeds under 1ghz - if [ -z "${speed:1}" ]; then - speed="0.${speed}" - else - speed=${speed:0:1}.${speed:1} - fi - cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) ;; esac + # Fix for speeds under 1ghz + if [ -z "${speed:1}" ]; then + speed="0.${speed}" + else + speed=${speed:0:1}.${speed:1} + fi + cpu="$cpu @ ${speed}GHz" ;; esac From fd1c8199ffd921e2256887d87ca987025e06caee Mon Sep 17 00:00:00 2001 From: dylan Date: Mon, 4 Apr 2016 21:35:56 +1000 Subject: [PATCH 03/11] Remove pointless matching --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index cf9747be..4ce86b4f 100755 --- a/neofetch +++ b/neofetch @@ -946,7 +946,7 @@ getcpu () { cores=$(sysctl -n hw.ncpu) ;; - "Linux" | *"BSD" | "Windows") + *) case "$distro" in "OpenBSD"* | "FreeBSD"*) # Get cpu name From 8520104000eb7f6ae0c9728f4c1f9ac4d5654477 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:10:13 +1000 Subject: [PATCH 04/11] os_arch, off by default --- config/config | 2 +- neofetch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config b/config/config index 8eb6012d..d46035c4 100644 --- a/config/config +++ b/config/config @@ -68,7 +68,7 @@ osx_codename="on" # Show 'x86_64' and 'x86' in 'Distro:' output. # --os_arch on/off -os_arch="on" +os_arch="off" # Uptime diff --git a/neofetch b/neofetch index 4ce86b4f..d9ccdd1d 100755 --- a/neofetch +++ b/neofetch @@ -94,7 +94,7 @@ osx_codename="on" # Show 'x86_64' and 'x86' in 'Distro:' output. # --os_arch on/off -os_arch="on" +os_arch="off" # Uptime From e75a67f92b70fb69ddbac36eb44bf1257a8b62f2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:12:45 +1000 Subject: [PATCH 05/11] Use uname to get the architecture --- neofetch | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/neofetch b/neofetch index d9ccdd1d..13ae60eb 100755 --- a/neofetch +++ b/neofetch @@ -452,10 +452,6 @@ esac # Distro {{{ -# Default bit style -x64="x86_64" -x32="x86" - case "$os" in "Linux" ) if type -p lsb_release >/dev/null 2>&1; then @@ -510,10 +506,6 @@ case "$os" in distro=${distro//[[:space:]]/ } distro=${distro// } distro=${distro/Microsoft } - - # Change bits to xx-bit for Windows - x64="64-bit" - x32="32-bit" ;; esac distro=${distro//+( )/ } @@ -521,12 +513,8 @@ ascii_distro="$distro" getdistro () { # Get architecture - if [ "$os_arch" == "on" ]; then - case "$(getconf LONG_BIT)" in - 64) distro+=" $x64" ;; - 32) distro+=" $x32" ;; - esac - fi + [ "$os_arch" == "on" ] && \ + distro+=" $(uname -m)" } From b07d18d6d0bd96da80ce9a0573745c0fdc99ddbc Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:16:54 +1000 Subject: [PATCH 06/11] Use 32-bit and 64-bit for arch --- neofetch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 13ae60eb..16e1b060 100755 --- a/neofetch +++ b/neofetch @@ -513,8 +513,12 @@ ascii_distro="$distro" getdistro () { # Get architecture - [ "$os_arch" == "on" ] && \ - distro+=" $(uname -m)" + [ "$os_arch" == "on" ] + case "$(getconf LONG_BIT)" in + 64) distro+=" 64-bit" ;; + 32) distro+=" 32-bit" ;; + esac + fi } From 8d67097a32d89c1dca80aa6db933331c4532103d Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:20:15 +1000 Subject: [PATCH 07/11] Fix broken cpu speed on NetBSD --- neofetch | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 16e1b060..2111c61b 100755 --- a/neofetch +++ b/neofetch @@ -977,11 +977,7 @@ getcpu () { speed=$((speed / 100000)) else speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) - - case "$distro" in - "NetBSD"*) speed=$((speed / 10000)) ;; - *) speed=$((speed / 100)) ;; - esac + speed=$((speed / 100)) fi cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo) From 8b69b26e601d07cfa1a26a88d717728ce92b9f61 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:21:17 +1000 Subject: [PATCH 08/11] Fix broken if syntax --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 2111c61b..3144805c 100755 --- a/neofetch +++ b/neofetch @@ -513,7 +513,7 @@ ascii_distro="$distro" getdistro () { # Get architecture - [ "$os_arch" == "on" ] + if [ "$os_arch" == "on" ]; then case "$(getconf LONG_BIT)" in 64) distro+=" 64-bit" ;; 32) distro+=" 32-bit" ;; From 49c9d78d5510c038d3a40f24ec198252d0346554 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:22:41 +1000 Subject: [PATCH 09/11] Revert setting change --- config/config | 2 +- neofetch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config b/config/config index d46035c4..8eb6012d 100644 --- a/config/config +++ b/config/config @@ -68,7 +68,7 @@ osx_codename="on" # Show 'x86_64' and 'x86' in 'Distro:' output. # --os_arch on/off -os_arch="off" +os_arch="on" # Uptime diff --git a/neofetch b/neofetch index 3144805c..c7e14746 100755 --- a/neofetch +++ b/neofetch @@ -94,7 +94,7 @@ osx_codename="on" # Show 'x86_64' and 'x86' in 'Distro:' output. # --os_arch on/off -os_arch="off" +os_arch="on" # Uptime From f306506c573a820e3bb97830250c296ea68c4add Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 4 Apr 2016 22:30:49 +1000 Subject: [PATCH 10/11] Fix xprop error in DE detection --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index c7e14746..14c19650 100755 --- a/neofetch +++ b/neofetch @@ -773,8 +773,8 @@ getde () { ;; esac - if [ -z "$de" ]; then - de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MARCO|^_MUFFIN|xfce4|xfce5/')" + if [ -n "$DISPLAY" ] && [ -z "$de" ]; then + de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MARCO|^_MUFFIN|xfce4|xfce5/' 2>/dev/null)" case "$de" in "KDE_SESSION_VERSION"*) de="KDE${de/* = }" ;; From a8cf5600f8caf7ec2ca412f99d3ad8a808653d13 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 5 Apr 2016 00:49:21 +1000 Subject: [PATCH 11/11] Use uname to get arch --- neofetch | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 14c19650..16f5a4a1 100755 --- a/neofetch +++ b/neofetch @@ -513,12 +513,8 @@ ascii_distro="$distro" getdistro () { # Get architecture - if [ "$os_arch" == "on" ]; then - case "$(getconf LONG_BIT)" in - 64) distro+=" 64-bit" ;; - 32) distro+=" 32-bit" ;; - esac - fi + [ "$os_arch" == "on" ] && \ + distro+=" $(uname -m)" }