From 8311d3f2e3e1a165470a5540eda8bb405efcda42 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 26 Mar 2016 22:13:03 +1100 Subject: [PATCH 01/16] Cleanup distro detection --- neofetch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index ecea09e8..ac1a647b 100755 --- a/neofetch +++ b/neofetch @@ -456,21 +456,18 @@ x32="x86" case "$os" in "Linux" ) if type -p lsb_release >/dev/null 2>&1; then - distro="$(lsb_release -d 2>/dev/null | awk -F':' '/Description/ {printf $2}')" + distro="$(lsb_release -d 2>/dev/null | awk -F ':' '/Description/ {printf $2}')" distro=${distro/[[:space:]]} elif type -p crux >/dev/null 2>&1; then distro="$(crux)" else - distro="$(grep -h '^NAME=' /etc/*ease)" + distro="$(awk -F 'NAME="|"' '/^NAME=/ {printf $2}' /etc/*ease)" # Workaround for distros that store the value differently. - [ -z "$distro" ] && distro="$(grep -h 'TAILS_PRODUCT_NAME' /etc/*ease)" + [ -z "$distro" ] && distro="$(awk -F 'TAILS_PRODUCT_NAME="|"' '/^TAILS_PRODUCT_NAME=/ {printf $2}' /etc/*ease)" [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" - - distro=${distro/*NAME\=} - distro=${distro//\"} fi ;; From 3584ebcf76b9b8daeb722fa097731054422fb98d Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 26 Mar 2016 22:32:31 +1100 Subject: [PATCH 02/16] Fix issues with Puppy Linux --- neofetch | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neofetch b/neofetch index ac1a647b..a95a14b8 100755 --- a/neofetch +++ b/neofetch @@ -2329,6 +2329,11 @@ colors () { setcolors 4 7 1 ;; + "Puppy"* | "Quirky Werewolf"* | "Precise Puppy"*) + setcolors 4 + ascii_distro="puppy" + ;; + "Scientific"*) setcolors 4 1 7 ;; From 95c744f0f8a0c0482947bad18552add1dad99a4e Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 26 Mar 2016 22:46:07 +1100 Subject: [PATCH 03/16] Merge Windows and Linux uptime blocks since they're the same --- neofetch | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index a95a14b8..988a32a6 100755 --- a/neofetch +++ b/neofetch @@ -554,9 +554,9 @@ getkernel() { getuptime () { case "$os" in - "Linux") + "Linux" | "Windows") case "$distro" in - "Puppy Linux"* | "Quirky Werewolf"* | "Precise Puppy"* | "Alpine Linux"*) + *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "Windows"*) uptime=$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}') uptime=${uptime/ / } ;; @@ -610,11 +610,6 @@ getuptime () { uptime="up $uptime" ;; - "Windows") - uptime=$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}') - uptime=${uptime/ / } - ;; - *) uptime="Unknown" ;; From b4f19e8a3d13f30424d45a08894e03525476102c Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 26 Mar 2016 23:17:27 +1100 Subject: [PATCH 04/16] Cleanup CPU function --- neofetch | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index 988a32a6..900e2d2f 100755 --- a/neofetch +++ b/neofetch @@ -819,11 +819,7 @@ getcpu () { case "$os" in "Linux") # 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 if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then @@ -841,8 +837,7 @@ getcpu () { /sys/devices/system/cpu/cpu0/cpufreq/${speed_type} else - speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) - speed=${speed/\.} + speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) fi # Convert mhz to ghz without bc From 912295d82128c354791f55bef45691e8f95f3654 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 26 Mar 2016 23:36:37 +1100 Subject: [PATCH 05/16] Remove all 'Unknown' printing when a command fails, instead we display nothing --- neofetch | 48 +++++------------------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/neofetch b/neofetch index 900e2d2f..2ab39c6c 100755 --- a/neofetch +++ b/neofetch @@ -511,10 +511,6 @@ case "$os" in x64="64-bit" x32="32-bit" ;; - - *) - distro="Unknown" - ;; esac ascii_distro="$distro" @@ -609,10 +605,6 @@ getuptime () { uptime="up $uptime" ;; - - *) - uptime="Unknown" - ;; esac # Make the output of uptime smaller. @@ -732,8 +724,6 @@ getpackages () { ;; esac packages=${packages// } - - [ -z "$packages" ] && packages="Unknown" } # }}} @@ -897,10 +887,6 @@ getcpu () { speed=${speed:0:1}.${speed:1} cpu="$cpu @ ${speed}GHz" ;; - - *) - cpu="Unknown" - ;; esac # Remove uneeded patterns from cpu output @@ -969,7 +955,8 @@ getgpu () { # If a GPU with a prefix of '3D' doesn't exist # fallback to looking for a prefix of 'VGA' [ -z "$gpu" ] && \ - gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" + gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" + gpu=${gpu//??':'??'.'?} # Count the number of GPUs @@ -1166,10 +1153,6 @@ getmemory () { memory="$((${memused%% *} / 1024))MB / " memory+="$((${memtotal%% *} / 1024))MB" ;; - - *) - memory="Unknown" - ;; esac # Progress bars @@ -1230,7 +1213,7 @@ getsong () { state="$(osascript -e 'tell application "iTunes" to player state as string')" else - song="Unknown" + song="Not Playing" fi case "$state" in @@ -1302,10 +1285,6 @@ getresolution () { [ ! -z "$width" ] && \ resolution="${width}x${height}" ;; - - "*") - resolution="Unknown" - ;; esac resolution=${resolution%,*} @@ -1515,9 +1494,8 @@ getdisk () { "Mac OS X") df_flags="-H / -l" ;; *"BSD") - case "$os" in - "FreeBSD") df_flags="-h -c -l" ;; - *) disk="Unknown"; return ;; + case "$distro" in + "FreeBSD"*) df_flags="-h -c -l" ;; esac ;; esac @@ -1673,10 +1651,6 @@ getlocalip () { "Windows") localip="$(ipconfig | awk -F ': ' '/IPv4 Address/ {printf $2}')" ;; - - *) - localip="Unknown" - ;; esac } @@ -1689,9 +1663,6 @@ getpublicip () { elif type -p wget >/dev/null 2>&1; then publicip="$(wget -qO- "$public_ip_host"; printf "%s")" - - else - publicip="Unknown" fi } @@ -1751,10 +1722,6 @@ getbirthday () { birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')" birthday_shorthand="on" ;; - - *) - birthday="Unknown" - ;; esac ;; @@ -1762,11 +1729,6 @@ getbirthday () { birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" date_cmd="$(date -d"$birthday" +"$birthday_format")" ;; - - *) - birthday="Unknown" - ;; - esac # Strip seconds from time output From d537b35695211907ecb88d7e58d3e64f384fcdad Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 11:11:41 +1100 Subject: [PATCH 06/16] Fix whitespace in OS X xeon cpu --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 2ab39c6c..ab4baf4f 100755 --- a/neofetch +++ b/neofetch @@ -840,7 +840,7 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - cpu=${cpu/ } + cpu=${cpu// } cores=$(sysctl -n hw.ncpu) ;; From f847d9ee22312ccdfa8484e9d7b1e30fad2dbd9e Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 11:15:12 +1100 Subject: [PATCH 07/16] Fix whitespace in OS X xeon cpu --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index ab4baf4f..786d5bcc 100755 --- a/neofetch +++ b/neofetch @@ -840,7 +840,7 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - cpu=${cpu// } + cpu=${cpu// } cores=$(sysctl -n hw.ncpu) ;; From 0c5869da38bdc6e8d290657a3fb5ea8afa2484f6 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 11:52:24 +1100 Subject: [PATCH 08/16] Fix weird whitespace issues with cores --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 786d5bcc..8c8072cc 100755 --- a/neofetch +++ b/neofetch @@ -903,7 +903,7 @@ getcpu () { # Add cpu cores to output [ "$cpu_cores" == "on" ] && [ ! -z "$cores" ] && \ - cpu=${cpu/@/\(${cores}\) @} + cpu=${cpu/ @/ \(${cores}\) @} # Make the output of cpu shorter case "$cpu_shorthand" in From eacce05f3aa95d99b50821ca435eaa57373cae01 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 11:59:01 +1100 Subject: [PATCH 09/16] Fixed broken CPU speed on linux when /sys/ wasn't available --- neofetch | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 8c8072cc..7c681907 100755 --- a/neofetch +++ b/neofetch @@ -826,12 +826,11 @@ getcpu () { 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 - - # Convert mhz to ghz without bc - speed=$((speed / 100000)) speed=${speed:0:1}.${speed:1} cpu="$cpu @ ${speed}GHz" @@ -903,7 +902,7 @@ getcpu () { # Add cpu cores to output [ "$cpu_cores" == "on" ] && [ ! -z "$cores" ] && \ - cpu=${cpu/ @/ \(${cores}\) @} + cpu=${cpu/@/\(${cores}\) @} # Make the output of cpu shorter case "$cpu_shorthand" in From 13f439502bed5562714c8244e889a7193337c508 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:03:40 +1100 Subject: [PATCH 10/16] Revert whitespace fix for OSx --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 7c681907..95c95854 100755 --- a/neofetch +++ b/neofetch @@ -839,7 +839,7 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - cpu=${cpu// } + cpu=${cpu/ } cores=$(sysctl -n hw.ncpu) ;; From d80d7e8c17592347c4ae23399a48e09c14ca702d Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:06:33 +1100 Subject: [PATCH 11/16] Added echo to debug --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 95c95854..c126fb3a 100755 --- a/neofetch +++ b/neofetch @@ -839,6 +839,7 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" + echo "$cpu" cpu=${cpu/ } cores=$(sysctl -n hw.ncpu) ;; From 9acf6d95549e48836be664dd61095ce62700e857 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:09:52 +1100 Subject: [PATCH 12/16] Fixed whitespace issue for realsies this time --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index c126fb3a..83fc90e9 100755 --- a/neofetch +++ b/neofetch @@ -839,8 +839,8 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - echo "$cpu" - cpu=${cpu/ } + cpu=${cpu// } + cpu=${cpu/ @ / @ } cores=$(sysctl -n hw.ncpu) ;; From 16f47e2f4e544d9e6573ce6d6d1c712be1903d94 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:12:25 +1100 Subject: [PATCH 13/16] I hate whitespace right now --- neofetch | 1 - 1 file changed, 1 deletion(-) diff --git a/neofetch b/neofetch index 83fc90e9..7c681907 100755 --- a/neofetch +++ b/neofetch @@ -840,7 +840,6 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" cpu=${cpu// } - cpu=${cpu/ @ / @ } cores=$(sysctl -n hw.ncpu) ;; From aa86f8ada28faabd55f262485f617ae315fc18d0 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:15:40 +1100 Subject: [PATCH 14/16] Revert all whitespace fixes for OSX --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 7c681907..95c95854 100755 --- a/neofetch +++ b/neofetch @@ -839,7 +839,7 @@ getcpu () { "Mac OS X") cpu="$(sysctl -n machdep.cpu.brand_string)" - cpu=${cpu// } + cpu=${cpu/ } cores=$(sysctl -n hw.ncpu) ;; From c27e70864d0b987c68b8987bd568251982308e44 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:20:34 +1100 Subject: [PATCH 15/16] Changelog --- 1.6.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/1.6.md b/1.6.md index 8ab9eb56..c64bb740 100644 --- a/1.6.md +++ b/1.6.md @@ -14,15 +14,19 @@ Thanks to the following people for contributing this release. - Fixed buggy colors in older versions of \*BSD, OS X and Linux. - Added Travis CI support. - Added `--test` which prints all functions. +- Cleanup of Distro, Uptime and CPU functions. ### Info +- Functions now no longer print `Unknown` when they fail, they now don't appear at all. + **OS**
- [ CRUX ] Also print the CRUX version. **[@onodera-punpun](https://github.com/onodera-punpun)** **CPU**
- [ Windows ] Don't print CPU cores if detection fails. - [ BSD ] Fixed extremely long output. +- Fixed broken CPU speed when source is `/proc/cpuinfo`. **GPU**
- Don't show GPU output on unsupported OS. @@ -40,10 +44,12 @@ Thanks to the following people for contributing this release. **Song**
- [ MPD ] Fixed function when mpd is running on another PC and not your own. +- Song now displays `Not Playing` instead of `Unknown` when no music player is found. - Added support for Google Play Music Desktop Player (adds optional dependency of [`gpmdp-bash`](https://github.com/iandrewt/gpmdp-bash)) **[@iandrewt](https://github.com/iandrewt)** **Disk**
- Added new display option `perc` to display just the percentage with the progress bar. +- Fixed disk usage not working on FreeBSD. **Memory**
- [ OpenBSD ] Fixed completely broken memory output on OpenBSD. @@ -67,6 +73,7 @@ Thanks to the following people for contributing this release. - Added ascii art for Qubes OS. - Added ascii art for Travis CI. - Revamped Alpine Linux's ascii art. +- Fixed missing ascii colors for Puppy Linux. - [ OSX ] Fixed incorrect text colors. From 2656aa5563b51793ec7651fed8212143bcfcdd0e Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 27 Mar 2016 12:22:01 +1100 Subject: [PATCH 16/16] Battery remove 'None' value --- neofetch | 2 -- 1 file changed, 2 deletions(-) diff --git a/neofetch b/neofetch index 95c95854..f1d84a6a 100755 --- a/neofetch +++ b/neofetch @@ -1574,8 +1574,6 @@ getbattery () { fi battery="${batteries[0]}%" fi - else - battery="None" fi ;;