lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
 
# defines
DIR="/sys/devices/virtual/thermal"
 
# helper function
direxists() {
  [ `adb shell "[ -d $1 ] && echo found"` ]
}
fileexists() {
  [ `adb shell "[ -f $1 ] && echo found"` ]
}
getprop() {
  if fileexists $1; then
    echo "`adb shell cat $1 | tr -d '\r'`"
  else
    echo "FILE $1 NOT FOUND"
  fi
}
print_if_exists() {
  if fileexists $1; then
    local ERROR=`getprop $1 | grep "Invalid"`
    if [ ${#ERROR} -eq 0 ]; then
      eval "$2=`getprop $1`"
    else
      eval "$2=ERROR"
    fi
  else
    eval "$2=DNE"
  fi
}
 
# setup
if [[ "`adb shell id | tr -d '\r' | awk -F'[()]' '{print $2}'`" != "root" ]]; then
  adb root
  adb wait-for-device
fi
 
# device name
echo Device: `adb shell getprop ro.product.model`
 
# get zones
ZONES=`adb shell ls $DIR | tr -d '\r' | grep thermal_zone | tr -d thermal_zone | sort -n`
 
# print temperature of each zone
for ZONE in $ZONES; do
  print_if_exists $DIR"/thermal_zone"$ZONE"/mode" MODE
  print_if_exists $DIR"/thermal_zone"$ZONE"/temp" TEMP
  print_if_exists $DIR"/thermal_zone"$ZONE"/type" TYPE
  printf "Zone %02d:   MODE=%-8s   TEMP=%-5s   TYPE=%s\n" $ZONE $MODE $TEMP $TYPE
done
 
# error
if ! direxists $DIR; then
  echo "Thermal directory not found"
fi