-
-
Save Lessica/30240b63ac0e47d80a919209ea006c60 to your computer and use it in GitHub Desktop.
#!/system/bin/sh | |
sleeptime=120 | |
while true | |
do | |
cputemp=$(cat /sys/class/thermal/thermal_zone0/temp) | |
if [[ $cputemp -lt 55000 ]]; then | |
fanspeed="0x00" | |
elif [ $cputemp -ge 55000 -a $cputemp -lt 60000 ]; then | |
fanspeed="0x10" | |
elif [ $cputemp -ge 60000 -a $cputemp -lt 65000 ]; then | |
fanspeed="0x32" | |
elif [ $cputemp -ge 65000 ]; then | |
fanspeed="0x64" | |
fi | |
i2cget -y 1 0x01a $fanspeed | |
sleep $sleeptime | |
done |
I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.
I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.
@Atomique13
I already follow your instruction but fan not working. my file path "/vendor/etc/init.d/".
@mshs013
I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.@Atomique13 I already follow your instruction but fan not working. my file path "/vendor/etc/init.d/".
@mshs013
Clone any other file from that folder, and edit it with your code (permissions were the culprit). Also change "#!/system/bin/sh" with "#!/vendor/bin/sh", I don't know if this is needed but in my case it worked. I've tested it on LineageOS 20 - KonstaKANG Android 13.
Good permissions (group 2000 in my case was edited as root by ubuntu, but still good)
just in case if your fan running on official gpio 14 pin or you have pwm controlled fan, you can use this script to control fan.
sleeptime=120
echo 14 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio14/direction
echo 0 > /sys/class/gpio/gpio14/value
echo `date` > /data/local/fan-script.log
while true
do
cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo $cputemp >> /data/local/fan-script.log
if [[ $cputemp -lt 55000 ]]; then
echo 0 > /sys/class/gpio/gpio14/value
elif [ $cputemp -ge 65000 ]; then
echo 1 > /sys/class/gpio/gpio14/value
fi
sleep $sleeptime
done
just in case if your fan running on official gpio 14 pin or you have pwm controlled fan, you can use this script to control fan.
sleeptime=120 echo 14 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio14/direction echo 0 > /sys/class/gpio/gpio14/value echo `date` > /data/local/fan-script.log while true do cputemp=$(cat /sys/class/thermal/thermal_zone0/temp) echo $cputemp >> /data/local/fan-script.log if [[ $cputemp -lt 55000 ]]; then echo 0 > /sys/class/gpio/gpio14/value elif [ $cputemp -ge 65000 ]; then echo 1 > /sys/class/gpio/gpio14/value fi sleep $sleeptime done
I'm using the case as it came, where should I copy this file to? thanks
@Lessica Can you explain this step by step? where to use this script and how.