summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rwxr-xr-xwidgets/temperatures/temperatures.g2v36
2 files changed, 24 insertions, 13 deletions
diff --git a/HISTORY b/HISTORY
index e1c031fc..64675548 100644
--- a/HISTORY
+++ b/HISTORY
@@ -17,6 +17,7 @@ VDR Plugin 'skinflatplus' Revision History
- [update] MV-Themes
- [update] timers widget - sort timers by time
- [update] system information widget - update system_information.g2v
+- [update] temperature widget - update temperatures.g2v
- [add] support for vdr-2.3.1
- [add] displaychannel - dvbapi info
you need oscam min rev 10653 and dvbapi min commit 85da7b2
diff --git a/widgets/temperatures/temperatures.g2v b/widgets/temperatures/temperatures.g2v
index 4f233f9e..b53a0f50 100755
--- a/widgets/temperatures/temperatures.g2v
+++ b/widgets/temperatures/temperatures.g2v
@@ -4,37 +4,47 @@
# this script is call every time the widget will be drawn, so keep it short and fast ;)
OUTPUTFLDR="/tmp/skinflatplus/widgets/temperatures"
-mkdir -p ${OUTPUTFLDR}
+mkdir -p "$OUTPUTFLDR"
# if the script is executed from system_information script set the locale back for "°C"
LANG=de_DE.UTF-8
# there can be 4 files, cpu, gpu, pccase, motherboard
-rm -f ${OUTPUTFLDR}/cpu ${OUTPUTFLDR}/gpu ${OUTPUTFLDR}/pccase ${OUTPUTFLDR}/motherboard
+rm -f "${OUTPUTFLDR}/cpu" "${OUTPUTFLDR}/gpu" \
+ "${OUTPUTFLDR}/pccase" "${OUTPUTFLDR}/motherboard"
# intel core-i cpu temp
-#sensors -A coretemp-isa-0000 | grep "Core 0" | awk '{print $3}' | tr -d "+" > ./cpu
+#sensors -A coretemp-isa-0000 | grep "Core 0" | awk '{print $3}' | tr -d "+" > "${OUTPUTFLDR}/cpu"
+
+# read sensors data
+mapfile -t < <(sensors -A)
+
+# cpu temp and motherboard temp
+for i in "${!MAPFILE[@]}" ; do
+ [[ "${MAPFILE[$i]}" =~ "CPU Temperature" ]] && CPUTEMP=(${MAPFILE[$i]})
+ [[ "${MAPFILE[$i]}" =~ "MB Temperature" ]] && MBTEMP=(${MAPFILE[$i]})
+ [[ -n "$CPUTEMP" && -n "$MBTEMP" ]] && break # both values found
+done
# cpu temp
-CPUTEMP=($(sensors -A | grep "CPU Temperature"))
-CPUTEMP[2]=${CPUTEMP[2]/+} # +36.0°C -> 36.0°C
-#echo "${CPUTEMP[2]/./,}" > ${OUTPUTFLDR}/cpu # 36,0°C
-echo "${CPUTEMP[2]%.*}°C" > ${OUTPUTFLDR}/cpu # 36°C
+#CPUTEMP=($(sensors -A | grep "CPU Temperature")) # no need for grep
+CPUTEMP[2]="${CPUTEMP[2]/+}" # +36.0°C -> 36.0°C
+#echo "${CPUTEMP[2]/./,}" > "${OUTPUTFLDR}/cpu" # 36,0°C
+echo "${CPUTEMP[2]%.*}°C" > "${OUTPUTFLDR}/cpu" # 36°C
# pc case temp
-#sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ${OUTPUTFLDR}/pccase
+#sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > "${OUTPUTFLDR}/pccase"
# motherboard temp
-MBTEMP=($(sensors -A | grep "MB Temperature"))
-MBTEMP[2]=${MBTEMP[2]/+} # +36.0°C -> 36.0°C
-#echo "${MBTEMP[2]/./,}" > ${OUTPUTFLDR}/motherboard # 36,0°C
-echo "${MBTEMP[2]%.*}°C" > ${OUTPUTFLDR}/motherboard # 36°C
+MBTEMP[2]="${MBTEMP[2]/+}" # +36.0°C -> 36.0°C
+#echo "${MBTEMP[2]/./,}" > "${OUTPUTFLDR}/motherboard" # 36,0°C
+echo "${MBTEMP[2]%.*}°C" > "${OUTPUTFLDR}/motherboard" # 36°C
# nvidia gpu temp
# nvidia-settings must be run as the user of the x server
#GPU=$(nvidia-settings -c :0 -t -query GPUCoreTemp | head -n 1) # slow
#GPU=$(nvidia-smi -q -d TEMPERATURE | grep -Pow "[[:digit:]]+(?=\sC)" | head -n1) # faster
GPU="$(/opt/bin/nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader)" # fastest
-echo "${GPU}°C" > ${OUTPUTFLDR}/gpu
+echo "${GPU}°C" > "${OUTPUTFLDR}/gpu"