diff options
author | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2016-08-20 14:22:35 +0200 |
---|---|---|
committer | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2016-08-20 14:22:35 +0200 |
commit | 5ce842f492e11e9c604747b97e8487339c7da753 (patch) | |
tree | fce40797b29500c0120c447df3a9d9ca7e77d25b /widgets/temperatures | |
parent | 4cbd9e01e49716306adf5e240bd3ddfec993ab9c (diff) | |
download | skin-flatplus-5ce842f492e11e9c604747b97e8487339c7da753.tar.gz skin-flatplus-5ce842f492e11e9c604747b97e8487339c7da753.tar.bz2 |
[update] temperature widget - update temperatures.g2v
Diffstat (limited to 'widgets/temperatures')
-rwxr-xr-x | widgets/temperatures/temperatures.g2v | 36 |
1 files changed, 23 insertions, 13 deletions
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" |