Merge pull request #1348 from lrusak/kodi-cputemp

kodi: adjust cputemp/gputemp script
This commit is contained in:
Christian Hewitt 2017-03-14 22:01:59 +04:00 committed by GitHub
commit ff51394de8

View File

@ -24,51 +24,52 @@
TEMP=0 TEMP=0
if [ $(basename "$0") = "gputemp" -o "$1" = "gpu" ]; then if [ $(basename "$0") = "gputemp" -o "$1" = "gpu" ]; then
if which lspci >/dev/null; then
if lspci -n | grep 0300 | grep -q 10de; then if [ -x /usr/bin/nvidia-smi ]; then
[ -x /usr/bin/nvidia-smi ] && TEMP=`/usr/bin/nvidia-smi -q -x | grep '<gpu_temp>' | awk '{ print $1 }' | sed 's,<gpu_temp>,,g'` TEMP="$(/usr/bin/nvidia-smi -q -x | grep '<gpu_temp>' | awk '{ print $1 }' | sed 's,<gpu_temp>,,g')"
fi fi
if [ "$TEMP" = "0" ]; then
for hwmon in /sys/class/hwmon/*; do
if [ -f "${hwmon}/name" ]; then
case $(cat ${hwmon}/name) in
nouveau|radeon)
[[ -f "${hwmon}/temp1_input" ]] && TEMP="$(cat ${hwmon}/temp1_input)" && break
[[ -f "${hwmon}/temp2_input" ]] && TEMP="$(cat ${hwmon}/temp2_input)" && break
;;
coretemp)
[[ -f "${hwmon}/temp1_input" ]] && TEMP="$(cat ${hwmon}/temp1_input)" && break
[[ -f "${hwmon}/temp2_input" ]] && TEMP="$(cat ${hwmon}/temp2_input)" && break
;;
esac
fi
done
TEMP="$(( $TEMP / 1000 ))"
fi fi
fi fi
if [ "$1" = "cpu" -o "$TEMP" = "0" ]; then if [ "$1" = "cpu" -o "$TEMP" = "0" ]; then
# used with coretemp for hwmon in /sys/class/hwmon/*; do
for hwmon in hwmon0 hwmon1; do if [ -f "${hwmon}/name" ]; then
for temp in temp1 temp2; do case $(cat ${hwmon}/name) in
if [ "$TEMP" = "0" -a -f /sys/class/hwmon/${hwmon}/${temp}_input ]; then coretemp|k10temp)
if [ -f /sys/class/hwmon/${hwmon}/name ]; then [[ -f "${hwmon}/temp1_input" ]] && TEMP="$(cat ${hwmon}/temp1_input)" && break
if [ ! "$(cat /sys/class/hwmon/${hwmon}/name)" = acpitz ]; then [[ -f "${hwmon}/temp2_input" ]] && TEMP="$(cat ${hwmon}/temp2_input)" && break
TEMP=$(cat /sys/class/hwmon/${hwmon}/${temp}_input) ;;
fi esac
fi fi
fi
done
done done
# used on AMD systems
if [ "$TEMP" = "0" -a -f /sys/class/hwmon/hwmon0/device/temp1_input ]; then if [ "$TEMP" = "0" -a -f /sys/class/hwmon/hwmon0/device/temp1_input ]; then
TEMP=`cat /sys/class/hwmon/hwmon0/device/temp1_input` TEMP="$(cat /sys/class/hwmon/hwmon0/device/temp1_input)"
fi fi
# used on ION systems # used on RaspberryPi and amlogic
if [ "$TEMP" = "0" -a -f /sys/class/hwmon/hwmon0/device/temp2_input ]; then
TEMP=`cat /sys/class/hwmon/hwmon0/device/temp2_input`
fi
# used on some intel systems
if [ "$TEMP" = "0" -a -f /sys/bus/acpi/devices/LNXTHERM\:00/thermal_zone/temp ]; then
TEMP=`cat /sys/bus/acpi/devices/LNXTHERM\:00/thermal_zone/temp`
fi
# used on some intel systems
if [ "$TEMP" = "0" -a -f /sys/devices/virtual/thermal/thermal_zone0/temp ]; then
TEMP=`cat /sys/devices/virtual/thermal/thermal_zone0/temp`
fi
# used on RaspberryPi
if [ "$TEMP" = "0" -a -f /sys/class/thermal/thermal_zone0/temp ]; then if [ "$TEMP" = "0" -a -f /sys/class/thermal/thermal_zone0/temp ]; then
TEMP=`cat /sys/class/thermal/thermal_zone0/temp` TEMP="$(cat /sys/class/thermal/thermal_zone0/temp)"
fi fi
TEMP="$(( $TEMP / 1000 ))" TEMP="$(( $TEMP / 1000 ))"