From 63b26285fb5d9d008693e6e45e3696f217429b6a Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Thu, 13 Jul 2017 18:42:44 +0700 Subject: [PATCH 1/3] CPU: Fix inaccurate speed for processors below 1GHz --- neofetch | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index fb411502..dc77bcc5 100755 --- a/neofetch +++ b/neofetch @@ -1014,18 +1014,13 @@ get_cpu() { esac if [[ "$speed" ]]; then - # Hide decimals if on. - [[ "$speed_shorthand" == "on" ]] && \ - speed="$((speed / 100))" - - # Fix for speeds under 1ghz. - if [[ -z "${speed:1}" ]]; then - speed="0.${speed}" + 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 - - cpu="$cpu @ ${speed}GHz $temp" fi # Remove un-needed patterns from cpu output. From 2e338529b87e767138dddcf7fa808d9e0732dffb Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Thu, 13 Jul 2017 19:04:42 +0700 Subject: [PATCH 2/3] Docs: Update manpage and config --- config/config.conf | 1 + neofetch | 3 +++ neofetch.1 | 2 ++ 3 files changed, 6 insertions(+) diff --git a/config/config.conf b/config/config.conf index 1575de10..ab9867d5 100644 --- a/config/config.conf +++ b/config/config.conf @@ -142,6 +142,7 @@ speed_type="bios_limit" # Default: 'off' # Values: 'on', 'off'. # Flag: --speed_shorthand. +# NOTE: This flag is not supported in systems with CPU speed less than 1 GHz # # Example: # on: 'i7-6500U (4) @ 3.1GHz' diff --git a/neofetch b/neofetch index dc77bcc5..aff94700 100755 --- a/neofetch +++ b/neofetch @@ -3951,6 +3951,9 @@ INFO: NOTE: This only supports Linux with cpufreq. --speed_shorthand on/off Whether or not to show decimals in CPU speed. + + 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_cores type Whether or not to display the number of CPU cores diff --git a/neofetch.1 b/neofetch.1 index 48b040ed..60557487 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -32,6 +32,8 @@ NOTE: This only supports Linux with cpufreq. .TP \fB\-\-speed_shorthand\fR on/off 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 From 8f975faa6b78ed62ad7f8c456d9001af71208e58 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Thu, 13 Jul 2017 19:06:15 +0700 Subject: [PATCH 3/3] Docs: CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b2e76c..a9ab9af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - [Linux] Fixed inaccurate output on ARM SoC devices. - [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. **Terminal**