gotosleep
gotosleep copied to clipboard
Computer still sleeps after battery depletion
If you set a sleep timer and the battery depletes before the timer reaches 0, the timer will resume when power is restored, and go to sleep when it reaches 0.
- Current time is 8:00am
- Invoke sleep in 30 minutes: gotosleep 1800
- Battery depletes after 10 minutes (8:10am)
- Computer is plugged into wall and restored power (10:00am)
- Script continues executing and goes into sleep state (10:20am)
This is in error, as the intended sleep time was 8:30am, but due to power loss, sleep state was at 10:20am.
Could fix by storing current UNIX time at instantiation and comparing for accuracy when time to invoke sleep. If invoke sleep time > actual sleep time, do not execute.