Cross-platform wakelock / keep-awake / stay-awake written in Python.
What is wakepy?
Wakepy is a package with an Python API and a CLI tool for keeping a system awake. It has two main modes:
⌛ Keeping CPU awake: For long running tasks. Inhibit the automatic, timer based sleep or suspend action, but allow screenlock and screensaver turning on and monitor turning off. E.g. for training machine learning models, video encoding and web scraping. (See: keep.running)
🖥️ Keeping screen awake: For long running tasks which require also the screen on and screenlock and screensaver inhibited. E.g. for showing a video and dashboard / monitoring apps. (See: keep.presenting)
[!NOTE]
To get the wakepyCLI command working, you might need to restart the shell / terminal application.
Why wakepy?
Here's some reasons why you might want to consider using wakepy:
🙅🏼♂️ Non-disruptive methods ✅
No mouse wiggling or pressing random keys like F15. Wakepy is completely non-disruptive. It uses the APIs and programs the system provides for keeping a system awake.
🛡️ Safe to crash 💥
No changing of any system settings; killing the process abruptly will not leave the keepawake on, and will not require any manual clean-up.
🚨 For security reasons 🔒
With keep.running mode you can disable just the automatic suspend and keep the automatic screen lock untouched.
🌐 You need a cross-platform solution 🦸
Same code works on Windows, macOS and Linux on multiple different Desktop Environments.
💪 You want to have more control ⚙️
It is possible to whitelist or blacklist the used wakepy Methods. It is also possible to prioritize them and define a on-fail action in case activating a wakepy mode fails.
✂️ You want to keep the amount of dependencies low 📦
If you're running wakepy on Linux, jeepney (a dependency free package) is required for D-Bus based methods. On Python 3.9 and earlier, typing-extensions is needed for typing. Otherwise: wakepy has no python dependencies.
Wakepy vision is to support any† environment which runs Python. The following runtime environments will get support in the future†. Please vote or comment on the issue to raise them towards top of priorities. I'm also happy to receive PRs or comments explaining how it could be implemented.
If you have ideas or comments, please post yours on wakepy/#317.
Licenses
The contents of this repository are licensed with MIT License, which is permissive and allows you to use the code as part of any application or library, commercial or not, with the following exception: The GitHub Invertocat logo used in the social share image is property of GitHub, downloaded from github.com/logos and is used under the terms specified by GitHub.
Footnotes
[1] Windows XP or higher. Windows Server 2003 or higher.
[2] Mac OS X 10.8 Mountain Lion (July 2012) or newer.
[3] GNOME 2.24 (Sept 2008) onwards.
[4] KDE Plasma 5.12.90 (May 2018) onwards.
[5] Freedesktop.org compliant Desktop Environments on Unix-like (Linux/BSD) system which implements the listed D-Bus interfaces.