Merge pull request #771 from konimex/cpu
CPU: Fix inaccurate speed for processors below 1GHz
This commit is contained in:
commit
1be4af24f2
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
- [Linux] Fixed inaccurate output on ARM SoC devices.
|
- [Linux] Fixed inaccurate output on ARM SoC devices.
|
||||||
- [NetBSD] Added support for CPU temperature. (NOTE: This only supports newer Intel processors)
|
- [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**
|
**Terminal**
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ speed_type="bios_limit"
|
||||||
# Default: 'off'
|
# Default: 'off'
|
||||||
# Values: 'on', 'off'.
|
# Values: 'on', 'off'.
|
||||||
# Flag: --speed_shorthand.
|
# Flag: --speed_shorthand.
|
||||||
|
# NOTE: This flag is not supported in systems with CPU speed less than 1 GHz
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# on: 'i7-6500U (4) @ 3.1GHz'
|
# on: 'i7-6500U (4) @ 3.1GHz'
|
||||||
|
|
16
neofetch
16
neofetch
|
@ -1014,19 +1014,14 @@ get_cpu() {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$speed" ]]; then
|
if [[ "$speed" ]]; then
|
||||||
# Hide decimals if on.
|
if (( speed < 1000 )); then
|
||||||
[[ "$speed_shorthand" == "on" ]] && \
|
cpu="$cpu @ ${speed}MHz $temp"
|
||||||
speed="$((speed / 100))"
|
|
||||||
|
|
||||||
# Fix for speeds under 1ghz.
|
|
||||||
if [[ -z "${speed:1}" ]]; then
|
|
||||||
speed="0.${speed}"
|
|
||||||
else
|
else
|
||||||
|
[[ "$speed_shorthand" == "on" ]] && speed="$((speed / 100))"
|
||||||
speed="${speed:0:1}.${speed:1}"
|
speed="${speed:0:1}.${speed:1}"
|
||||||
fi
|
|
||||||
|
|
||||||
cpu="$cpu @ ${speed}GHz $temp"
|
cpu="$cpu @ ${speed}GHz $temp"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove un-needed patterns from cpu output.
|
# Remove un-needed patterns from cpu output.
|
||||||
cpu="${cpu//(TM)}"
|
cpu="${cpu//(TM)}"
|
||||||
|
@ -3956,6 +3951,9 @@ INFO:
|
||||||
NOTE: This only supports Linux with cpufreq.
|
NOTE: This only supports Linux with cpufreq.
|
||||||
|
|
||||||
--speed_shorthand on/off Whether or not to show decimals in CPU speed.
|
--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
|
--cpu_shorthand type Shorten the output of CPU
|
||||||
Possible values: name, speed, tiny, on, off
|
Possible values: name, speed, tiny, on, off
|
||||||
--cpu_cores type Whether or not to display the number of CPU cores
|
--cpu_cores type Whether or not to display the number of CPU cores
|
||||||
|
|
|
@ -32,6 +32,8 @@ NOTE: This only supports Linux with cpufreq.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-speed_shorthand\fR on/off
|
\fB\-\-speed_shorthand\fR on/off
|
||||||
Whether or not to show decimals in CPU speed.
|
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
|
.TP
|
||||||
\fB\-\-cpu_shorthand\fR type
|
\fB\-\-cpu_shorthand\fR type
|
||||||
Shorten the output of CPU
|
Shorten the output of CPU
|
||||||
|
|
Reference in New Issue