CPU: Add CPU temp separately instead of embedding them in speed

This commit is contained in:
Muhammad Herdiansyah 2017-07-20 22:34:48 +07:00
parent 92b68e506e
commit fe9a379d8c
1 changed files with 25 additions and 30 deletions

View File

@ -868,15 +868,9 @@ get_cpu() {
fi fi
# Get CPU temp. # Get CPU temp.
if [[ "$cpu_temp" != "off" && -f "$temp_dir" ]]; then if [[ -f "$temp_dir" ]]; then
temp="$(< "$temp_dir")" temp="$(< "$temp_dir")"
temp="$((temp * 100 / 10000))" temp="$((temp * 100 / 10000))"
# Convert to fahrenheit if enabled.
[[ "$cpu_temp" == "F" ]] && temp="$((temp * 90 / 50 + 320))"
# Format the output.
temp="[${temp/${temp: -1}}.${temp: -1}°${cpu_temp:-C}]"
fi fi
# Get CPU cores. # Get CPU cores.
@ -937,7 +931,6 @@ get_cpu() {
cores="$(sysctl -n hw.ncpu)" cores="$(sysctl -n hw.ncpu)"
# Get CPU temp. # Get CPU temp.
if [[ "$cpu_temp" != "off" ]]; then
case "$kernel_name" in case "$kernel_name" in
"FreeBSD"* | "DragonFly"* | "NetBSD"*) "FreeBSD"* | "DragonFly"* | "NetBSD"*)
temp="$(sysctl -n dev.cpu.0.temperature)" temp="$(sysctl -n dev.cpu.0.temperature)"
@ -948,16 +941,6 @@ get_cpu() {
temp="${temp/ degC}" temp="${temp/ degC}"
;; ;;
esac esac
# Convert to fahrenheit if enabled.
if [[ "$cpu_temp" == "F" ]]; then
temp="${temp//.}"
temp="$((temp * 90 / 50 + 320))"
temp="[${temp/${temp: -1}}.${temp: -1}°F]"
else
temp="[${temp}°C]"
fi
fi
;; ;;
"Solaris") "Solaris")
@ -1060,13 +1043,25 @@ get_cpu() {
# Add CPU speed to the output. # Add CPU speed to the output.
if [[ "$cpu_speed" != "off" && "$speed" ]]; then if [[ "$cpu_speed" != "off" && "$speed" ]]; then
if (( speed < 1000 )); then if (( speed < 1000 )); then
cpu="$cpu @ ${speed}MHz $temp" cpu="$cpu @ ${speed}MHz"
else else
[[ "$speed_shorthand" == "on" ]] && speed="$((speed / 100))" [[ "$speed_shorthand" == "on" ]] && speed="$((speed / 100))"
speed="${speed:0:1}.${speed:1}" speed="${speed:0:1}.${speed:1}"
cpu="$cpu @ ${speed}GHz $temp" cpu="$cpu @ ${speed}GHz"
fi fi
fi fi
# Add CPU temp to the output.
if [[ "$cpu_temp" != "off" && "$temp" ]]; then
temp="${temp//.}"
# Convert to Fahrenheit if enabled
[[ "$cpu_temp" == "F" ]] && temp="$((temp * 90 / 50 + 320))"
# Format the output
temp="[${temp/${temp: -1}}.${temp: -1}°${cpu_temp:-C}]"
cpu="$cpu $temp"
fi
} }
get_cpu_usage() { get_cpu_usage() {