power.hold()function
This function prevents the computer from going into sleep mode. Call power.unhold() to permit sleep mode again.
- This function does not block user-initiated sleep: If the user closes the lid, presses the power button, or selects Sleep manually, the system will still sleep.
- On newer devices (especially laptops), the request may be ignored or auto-terminated after 5 minutes on battery power.
Return value
This function returns
true on success or
false otherwise.
Example
--! luart-extensions
import power
print("Preventing the computer to go to sleep mode for 5sec")
print(power.hold())
sleep(5000)
print("Computer can now go to sleep")
print(power.unhold())