Skip to content

Commit 99e7ef7

Browse files
committed
Merge remote-tracking branch 'origin/temp_unit'
2 parents 8a29186 + 88ba243 commit 99e7ef7

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Here are all available options with their default values:
135135
@ram_(low_icon,high_bg_color,etc...) # same defaults as above
136136

137137
@cpu_temp_format "%2.0f" # printf format to use to display temperature
138-
@cpu_temp_units "C" # supports C & F
138+
@cpu_temp_unit "C" # supports C & F
139139

140140
@cpu_temp_medium_thresh "80" # medium temperature threshold
141141
@cpu_temp_high_thresh "90" # high temperature threshold

scripts/cpu_temp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ print_cpu_temp() {
1111
cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format")
1212
cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit")
1313
if command_exists "sensors"; then
14-
([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | 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)}'
14+
([ "$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)}'
1515
fi
1616
}
1717

scripts/gpu_temp.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
source "$CURRENT_DIR/helpers.sh"
66

77
gpu_temp_format="%2.0f"
8+
gpu_temp_unit="C"
89

910
print_gpu_temp() {
1011
gpu_temp_format=$(get_tmux_option "@gpu_temp_format" "$gpu_temp_format")
12+
gpu_temp_unit=$(get_tmux_option "@gpu_temp_unit" "$gpu_temp_unit")
1113

1214
if command_exists "nvidia-smi"; then
1315
loads=$(cached_eval nvidia-smi)
@@ -17,7 +19,12 @@ print_gpu_temp() {
1719
echo "No GPU"
1820
return
1921
fi
20-
echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk -v format="${gpu_temp_format}C" '{sum+=$1; n+=1} END {printf format, sum/n}'
22+
tempC=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk '{sum+=$1; n+=1} END {printf "%5.3f", sum/n}')
23+
if [ $gpu_temp_unit == "C" ]; then
24+
echo "$tempC" | awk -v format="${gpu_temp_format}C" '{sum+=$1} END {printf format, sum}'
25+
else
26+
echo "$tempC" | awk -v format="${gpu_temp_format}F" '{sum+=$1} END {printf format, sum*9/5+32}'
27+
fi
2128
}
2229

2330
main() {

0 commit comments

Comments
 (0)