From 2e1c942491ad8d34d64ee0b0d0677c95b4f076a0 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 14 Jul 2017 02:25:17 +0700 Subject: [PATCH 1/3] CPU [Speed]: Use the cpu_cores approach instead of deleting it manually. This way, we don't have to replace the "@" with "($cores) @" and remove the CPU speed from the output. --- neofetch | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/neofetch b/neofetch index aff94700..7d8c0240 100755 --- a/neofetch +++ b/neofetch @@ -1013,16 +1013,6 @@ get_cpu() { ;; esac - if [[ "$speed" ]]; then - if (( speed < 1000 )); then - cpu="$cpu @ ${speed}MHz $temp" - else - [[ "$speed_shorthand" == "on" ]] && speed="$((speed / 100))" - speed="${speed:0:1}.${speed:1}" - cpu="$cpu @ ${speed}GHz $temp" - fi - fi - # Remove un-needed patterns from cpu output. cpu="${cpu//(TM)}" cpu="${cpu//(tm)}" @@ -1047,11 +1037,18 @@ get_cpu() { # Add CPU cores to the output. [[ "$cpu_cores" != "off" && "$cores" ]] && \ - cpu="${cpu/@/(${cores}) @}" + cpu="$cpu ($cores)" - # Remove CPU speed from the output. - [[ "$cpu_speed" == "off" ]] && \ - cpu="${cpu/@ *GHz}" + # Add CPU speed to the output. + if [[ "$cpu_speed" != "off" && "$speed" ]]; then + if (( speed < 1000 )); then + cpu="$cpu @ ${speed}MHz $temp" + else + [[ "$speed_shorthand" == "on" ]] && speed="$((speed / 100))" + speed="${speed:0:1}.${speed:1}" + cpu="$cpu @ ${speed}GHz $temp" + fi + fi # Make the output of CPU shorter. case "$cpu_shorthand" in From 91372f1cdef67594005084161f73d794350d1873 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 14 Jul 2017 02:36:07 +0700 Subject: [PATCH 2/3] CPU [Linux]: Add fallback speed method for PowerPC systems. --- CHANGELOG.md | 1 + neofetch | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ec7a5f..4173e6c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ **CPU** - [Linux] Fixed inaccurate output on ARM SoC devices. +- [Linux] Fixed CPU speed not appearing on PowerPC systems. - [NetBSD] Added support for CPU temperature. (NOTE: This only supports newer Intel processors) - Fixed inaccurate speed output in systems with CPU speed less than 1 GHz. diff --git a/neofetch b/neofetch index 7d8c0240..e0574c2c 100755 --- a/neofetch +++ b/neofetch @@ -859,7 +859,8 @@ get_cpu() { speed="$((speed / 1000))" else - speed="$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)" + speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' /proc/cpuinfo)" + speed="${speed/MHz}" fi # Get CPU temp. From a503fb975cbf0bd3ac1da76ecde68114e24d4bce Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 14 Jul 2017 13:53:09 +0700 Subject: [PATCH 3/3] CPU: Deprecate cpu_shorthand in favor of cpu_brand --- CHANGELOG.md | 1 + config/config.conf | 17 +++++++---------- neofetch | 31 +++++++++++++------------------ neofetch.1 | 5 ++--- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4173e6c2..9142d682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [Linux] Fixed CPU speed not appearing on PowerPC systems. - [NetBSD] Added support for CPU temperature. (NOTE: This only supports newer Intel processors) - Fixed inaccurate speed output in systems with CPU speed less than 1 GHz. +- Deprecated `cpu_shorthand` in favor of `cpu_brand`. **Terminal** diff --git a/config/config.conf b/config/config.conf index 5c87b439..33b3cf82 100644 --- a/config/config.conf +++ b/config/config.conf @@ -149,19 +149,16 @@ speed_type="bios_limit" # off: 'i7-6500U (4) @ 3.100GHz' speed_shorthand="off" -# Shorten the output of the CPU function +# Enable/Disable CPU brand in output. # -# Default: 'off' -# Values: 'on', 'off', 'tiny', 'name', 'speed' -# Flag: --cpu_shorthand +# Default: 'on' +# Values: 'on', 'off' +# Flag: --cpu_brand # # Example: -# on: 'i7-6500U (4) @ 3.1GHz' -# off: 'Intel i7-6500U (4) @ 3.1GHz' -# tiny: 'i7-6500U (4)' -# name: 'Intel i7-6500U (4)' -# speed: '3.1GHz' -cpu_shorthand="off" +# on: 'Intel i7-6500U' +# off: 'i7-6500U (4)' +cpu_brand="on" # CPU Speed # Hide/Show CPU speed. diff --git a/neofetch b/neofetch index e0574c2c..bbf653b4 100755 --- a/neofetch +++ b/neofetch @@ -1036,6 +1036,14 @@ get_cpu() { # Trim spaces from core output cores="${cores//[[:space:]]}" + # Remove CPU brand from the output. + if [[ "$cpu_brand" == "off" ]]; then + cpu="${cpu/AMD }" + cpu="${cpu/Intel }" + cpu="${cpu/Core? Duo }" + cpu="${cpu/Qualcomm }" + fi + # Add CPU cores to the output. [[ "$cpu_cores" != "off" && "$cores" ]] && \ cpu="$cpu ($cores)" @@ -1050,21 +1058,6 @@ get_cpu() { cpu="$cpu @ ${speed}GHz $temp" fi fi - - # Make the output of CPU shorter. - case "$cpu_shorthand" in - "name") cpu="${cpu/@*}" ;; - "speed") cpu="${cpu#*@ }" ;; - - "on" | "tiny") - cpu="${cpu/AMD }" - cpu="${cpu/Intel }" - cpu="${cpu/Core? Duo }" - cpu="${cpu/Qualcomm }" - - [[ "$cpu_shorthand" == "tiny" ]] && cpu="${cpu/@*}" - ;; - esac } get_cpu_usage() { @@ -3799,6 +3792,9 @@ old_options() { # Scrot dir was removed in 3.1.0. [[ -n "$scrot_dir" ]] && scrot_dir= + + # cpu_shorthand was deprecated in 3.3.0 + [[ -n "$cpu_shorthand" ]] && { err "Config: \$cpu_shorthand is deprecated, use \$cpu_brand, \$cpu_cores, and \$cpu_speed instead."; } } cache_uname() { @@ -3952,8 +3948,7 @@ INFO: NOTE: This flag is not supported in systems with CPU speed less than 1 GHz. - --cpu_shorthand type Shorten the output of CPU - Possible values: name, speed, tiny, on, off + --cpu_brand on/off Enable/Disable CPU brand in output. --cpu_cores type Whether or not to display the number of CPU cores Possible values: logical, physical, off @@ -4168,7 +4163,7 @@ get_args() { "--distro_shorthand") distro_shorthand="$2" ;; "--kernel_shorthand") kernel_shorthand="$2" ;; "--uptime_shorthand") uptime_shorthand="$2" ;; - "--cpu_shorthand") cpu_shorthand="$2" ;; + "--cpu_brand") cpu_brand="$2" ;; "--gpu_brand") gpu_brand="$2" ;; "--gpu_type") gpu_type="$2" ;; "--refresh_rate") refresh_rate="$2" ;; diff --git a/neofetch.1 b/neofetch.1 index 60557487..71c699b0 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -35,9 +35,8 @@ Whether or not to show decimals in CPU speed. .IP NOTE: This flag is not supported in systems with CPU speed less than 1 GHz. .TP -\fB\-\-cpu_shorthand\fR type -Shorten the output of CPU -Possible values: name, speed, tiny, on, off +\fB\-\-cpu_brand\fR on/off +Enable/Disable CPU brand in output. .TP \fB\-\-cpu_cores\fR type Whether or not to display the number of CPU cores