Advertisement
metalx1000

Android power off on AC disconnect

Dec 16th, 2023
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.26 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #start this script with nohup /data/local/tmp/check_power
  4. function main(){
  5.         power="$(dumpsys battery|grep "AC powered"|awk '{print $3}')"
  6.         [[ "$power" == "true" ]] || reboot
  7.         sleep 1
  8. }
  9.  
  10. while [ 1 ]
  11. do
  12.         main
  13. done
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement