Skip to content

Instantly share code, notes, and snippets.

@Dgzt
Created November 1, 2021 18:11
Show Gist options
  • Save Dgzt/918bacb54467d7ac5b8f1c4523345064 to your computer and use it in GitHub Desktop.
Save Dgzt/918bacb54467d7ac5b8f1c4523345064 to your computer and use it in GitHub Desktop.
Show temperatures in one line with optitonal counter
#!/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