What Is Script Daemon Mode?
- Daemon mode ensures that if a script is terminated by external factors (e.g. service crash, power loss), it will automatically relaunch once the device returns to a normal state. Exceptions:
- The device runs out of power and is never recharged
- The device cannot boot
- Jailbreak state is lost after reboot
- The device is in Safe Mode
- The device has a passcode and is rebooted
- Manually terminated by user
- Script terminated due to a runtime error
- Daemon mode launches before the boot-time script. After an unexpected reboot, you can add the following code at the beginning of your script to ensure the screen is unlocked before proceeding:
while (device.is_screen_locked()) do
device.unlock_screen()
sys.msleep(1000)
end
sys.toast("Screen unlocked. Script starts.")
-- Your script continues below
-- ...