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.
This commit is contained in:
Muhammad Herdiansyah 2017-07-14 02:25:17 +07:00
parent 1378d3b33e
commit 2e1c942491
1 changed files with 11 additions and 14 deletions

View File

@ -1013,16 +1013,6 @@ get_cpu() {
;; ;;
esac 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. # Remove un-needed patterns from cpu output.
cpu="${cpu//(TM)}" cpu="${cpu//(TM)}"
cpu="${cpu//(tm)}" cpu="${cpu//(tm)}"
@ -1047,11 +1037,18 @@ get_cpu() {
# Add CPU cores to the output. # Add CPU cores to the output.
[[ "$cpu_cores" != "off" && "$cores" ]] && \ [[ "$cpu_cores" != "off" && "$cores" ]] && \
cpu="${cpu/@/(${cores}) @}" cpu="$cpu ($cores)"
# Remove CPU speed from the output. # Add CPU speed to the output.
[[ "$cpu_speed" == "off" ]] && \ if [[ "$cpu_speed" != "off" && "$speed" ]]; then
cpu="${cpu/@ *GHz}" 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. # Make the output of CPU shorter.
case "$cpu_shorthand" in case "$cpu_shorthand" in