Created
November 1, 2021 18:11
-
-
Save Dgzt/918bacb54467d7ac5b8f1c4523345064 to your computer and use it in GitHub Desktop.
Show temperatures in one line with optitonal counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "$1" ]]; then | |
num="$1" | |
else | |
num="1" | |
fi | |
if [[ ! $num == ?(-)+([0-9]) ]]; then | |
echo "The given value is not integer!" >&2; exit 1 | |
fi | |
counter=0 | |
while [ $counter -lt $num ]; do | |
text=$(sensors -j) | |
cpuTemp=$(jq '."dell_smm-virtual-0"."CPU"."temp1_input"' <<< "$text") | |
gpuTemp=$(jq '."dell_smm-virtual-0"."GPU"."temp5_input"' <<< "$text") | |
sodimmTemp=$(jq '."dell_smm-virtual-0"."SODIMM"."temp3_input"' <<< "$text") | |
ambientTemp=$(jq '."dell_smm-virtual-0"."Ambient"."temp2_input"' <<< "$text") | |
echo "CPU: ${cpuTemp} C, GPU: ${gpuTemp} C, SODIMM: ${sodimmTemp} C, Ambient: ${ambientTemp} C" | |
((counter++)) | |
if [[ $num -ne $counter ]]; then | |
sleep 1 | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment