cpu_temp: $temp is an environment variable on Windows.

This commit is contained in:
dylan araps 2017-12-13 11:48:49 +11:00
parent 9f263fe184
commit a2290b7398
1 changed files with 11 additions and 11 deletions

View File

@ -949,8 +949,8 @@ get_cpu() {
# Get CPU temp. # Get CPU temp.
if [[ -f "$temp_dir" ]]; then if [[ -f "$temp_dir" ]]; then
temp="$(< "$temp_dir")" deg="$(< "$temp_dir")"
temp="$((temp * 100 / 10000))" deg="$((deg * 100 / 10000))"
fi fi
# Get CPU cores. # Get CPU cores.
@ -1013,12 +1013,12 @@ get_cpu() {
# Get CPU temp. # Get CPU temp.
case "$kernel_name" in case "$kernel_name" in
"FreeBSD"* | "DragonFly"* | "NetBSD"*) "FreeBSD"* | "DragonFly"* | "NetBSD"*)
temp="$(sysctl -n dev.cpu.0.temperature)" deg="$(sysctl -n dev.cpu.0.temperature)"
temp="${temp/C}" deg="${deg/C}"
;; ;;
"OpenBSD"* | "Bitrig"*) "OpenBSD"* | "Bitrig"*)
temp="$(sysctl -n hw.sensors.lm0.temp0)" deg="$(sysctl -n hw.sensors.lm0.temp0)"
temp="${temp/ degC}" deg="${deg/ degC}"
;; ;;
esac esac
;; ;;
@ -1135,15 +1135,15 @@ get_cpu() {
fi fi
# Add CPU temp to the output. # Add CPU temp to the output.
if [[ "$cpu_temp" != "off" && "$temp" ]]; then if [[ "$cpu_temp" != "off" && "$deg" ]]; then
temp="${temp//.}" deg="${deg//.}"
# Convert to Fahrenheit if enabled # Convert to Fahrenheit if enabled
[[ "$cpu_temp" == "F" ]] && temp="$((temp * 90 / 50 + 320))" [[ "$cpu_temp" == "F" ]] && deg="$((deg * 90 / 50 + 320))"
# Format the output # Format the output
temp="[${temp/${temp: -1}}.${temp: -1}°${cpu_temp:-C}]" deg="[${deg/${deg: -1}}.${deg: -1}°${cpu_temp:-C}]"
cpu="$cpu $temp" cpu="$cpu $deg"
fi fi
} }