From 09379eebc08658626b91098444c4d740b95dc5ec Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 14 Apr 2023 20:13:18 +0100 Subject: [PATCH] Handle AMD CPU temp on ASUS motherboards --- system-info/system-info-Linux.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/system-info/system-info-Linux.sh b/system-info/system-info-Linux.sh index de22269..25f18a4 100755 --- a/system-info/system-info-Linux.sh +++ b/system-info/system-info-Linux.sh @@ -8,6 +8,20 @@ if [ ! -d $cache_dir ]; then mkdir -p $cache_dir fi +if sensors 'coretemp-isa-0000' &> /dev/null; then + function get_cpu_temp() { + sensors coretemp-isa-0000 | awk 'NR == 3 { print substr($4, 2) }' + } +elif sensors 'asus_wmi_sensors-virtual-0' &> /dev/null; then + function get_cpu_temp { + sensors asus_wmi_sensors-virtual-0 | grep 'CPU Temperature' | awk '{ print $3 }' + } +else + function get_cpu_temp { + echo 'cpu temp not available' + } +fi + # Cleanup cache file when interrupted. trap '[ -f $cache_file ] && rm $cache_file; exit' INT trap '[ -f $cache_file ] && rm $cache_file; exit' TERM @@ -18,7 +32,7 @@ while true; do jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \ awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'` # Parse the current CPU package temperature. - cpu_temp=`sensors coretemp-isa-0000 | awk 'NR == 3 { print substr($4, 2) }'` + cpu_temp=$(get_cpu_temp) # Write to the cache file. echo "$cpu_temp $cpu_load" > $cache_file done