Fix SC2015

https://github.com/koalaman/shellcheck/wiki/SC2015
This commit is contained in:
Camille TJHOA 2021-10-22 12:35:23 +00:00
parent ad2bf265ca
commit 987da7ade3

View file

@ -12,7 +12,13 @@ print_cpu_temp() {
cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format")
cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit")
if command_exists "sensors"; then
([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
local val
if [[ "$cpu_temp_unit" == F ]]; then
val=$(sensors -f)
else
val=$(sensors)
fi
val | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
fi
}