Python API#
- wakepy.keep.running()#
Keep the system running your programs; Prevent system from sleeping / suspending automatically. Does not keep display on, and does not prevent automatic screen lock or screen saver.
Example
from wakepy import keep with keep.running() as m: if not m.success: # optional: signal to user? # Do something that takes a long time but does not need to be # displayed.
- wakepy.keep.presenting()#
Keep the system running your programs and showing some content; Prevent screen saver and screen locker from switching on. Implies that system is prevented from sleeping / suspending automatically.
Example
from wakepy import keep with keep.presenting() as m: if not m.success: # optional: signal to user? # Do something that takes a long time and needs # to be shown to user; no automatic screen lock
Warning
๐ Since screen will not be automatically locked, you donโt want to leave your machine unattended in an insecure place.
Deprecated API#
These functions are deprecated in wakepy 0.7.0 and should not be used. They will be removed in a subsequent release.
- wakepy.keepawake(*args, **kwargs)#
DEPRECATED in wakepy 0.7.0. Use
keep.running()orkeep.presenting(), instead.This is the (old) context manager for setting and unsetting keepawake.
Example
>>> with keepawake(): ... # do something
- wakepy.set_keepawake(keep_screen_awake: bool = False)#
DEPRECATED in wakepy 0.7.0. Use
keep.running()orkeep.presenting(), instead.Set a wakelock for keeping system awake (disallow susped/sleep). This is lower level function, and usage of the
keepawake()context manager is recommended for most situations, as to unset the keepawake, same (first succesful) method should be used inunset_keepawake().- Parameters:
keep_screen_awake (bool) โ
- If True, keeps also the screen awake, if implemented on system.
windows: works (default: False)
linux: always True and cannot be changed.
mac: ? (untested)
- wakepy.unset_keepawake()#
DEPRECATED in wakepy 0.7.0. Use
keep.running()orkeep.presenting(), instead.Uset a wakelock (allow susped/sleep again). This is lower level function, and usage of the
keepawake()context manager is recommended for most situations, as to unset the keepawake, same (first succesful) method ofset_keepawake()should be used here.