Last active
February 15, 2023 09:15
-
-
Save ouija/a1e5389172bd79c75977ae9671b639fc to your computer and use it in GitHub Desktop.
Android-x86 "Suspend-To-Idle" (freeze power state) script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
# sleep fix script by @ouija - for baytrail/cherrytrail devices that only support 'Suspend-to-Idle' or freeze power state | |
while true | |
do | |
# get device wakefulness state | |
WAKE_STATE=$(dumpsys power | grep -m1 'mWakefulness' | cut -d = -f 2) | |
# get current power state | |
PWR_STATE=$(cat /sys/power/state) | |
# inital check to see if device asleep and power state is default | |
if [ "$WAKE_STATE" = "Asleep" ] && [ "$PWR_STATE" = "freeze mem" ]; then | |
# wait 30 seconds before doing anything | |
sleep 29 | |
# verify device wakefulness state as asleep | |
WAKE_STATE_VERIFY=$(dumpsys power | grep -m1 'mWakefulness' | cut -d = -f 2) | |
# verify current power state as default | |
PWR_STATE_VERIFY=$(cat /sys/power/state) | |
if [ "$WAKE_STATE_VERIFY" = "Asleep" ] && [ "$PWR_STATE_VERIFY" = "freeze mem" ]; then | |
# all systems go, let's freeze the bitch | |
echo freeze > /sys/power/state | |
fi | |
fi | |
# check sleep state every second | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment