Skip to main content

Simple wakelock / keep-awake / stay-awake

Project description

GitHub tag (latest by date) PyPI PyPI - Downloads GitHub

⏰😴 wakepy

Simple cross-platform wakelock written in Python. Keeps your computer from going to sleep.

Table of Contents

Requirements

Wakepy currently supports

  • Windows
  • Linux (with systemd)
  • macOS

Feel free to submit pull request(s) for other platforms.

Installing

pip install wakepy

Usage

Start from command line

python -m wakepy

Starts the program. While running, computer will not go to sleep. If battery is running out, your OS might force laptop to sleep.

CLI

python -m wakepy [-h] [-s]

optional arguments:    
  -h, --help               show this help message and exit
  -s, --keep-screen-awake  Keep also the screen awake. On Linux, this flag is set on and cannot be disabled.

Set keepawake within a python script

from wakepy import set_keepawake, unset_keepawake

set_keepawake(keep_screen_awake=False)
# do stuff that takes long time
unset_keepawake()

Parameters

  • keep_screen_awake can be used to keep also the screen awake. The default is False. On Linux, this is set to True and cannot be changed.

Details

Windows

The program simply calls the SetThreadExecutionState with the ES_SYSTEM_REQUIRED flag, when setting the keepawake, and removes flag when unsetting. The flag cannot prevent sleeping if

  • User presses power button
  • User selects Sleep from the Start menu.

Linux

The program uses the systemctl mask command to prevent all forms of sleep or hybernation when setting the keepawake, and unmasks the functions when unsetting keepawake. This command will remain active until keepawake is removed. The flag cannot prevent sleeping from user interaction. This action does require sudo privileges.

Darwin (macOS)

The program calls the caffeinate command when setting keepawake, and sends a break key-command when unsetting. The flag does not prevent the user from manually sleeping the system or terminating the caffeinate process.

Changelog

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wakepy-0.3.2.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file wakepy-0.3.2.tar.gz.

File metadata

  • Download URL: wakepy-0.3.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for wakepy-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6bb29165660f5aefb49fdf806f7c80fe2f54c98fc29fe85281b724f565ef08ae
MD5 2c35d68de0b03a00a0a9797d64ec580c
BLAKE2b-256 9e33e58ab32b4cf19f0ea277f88e317ca10aed8d509b5cb8657ce6ec51028d2d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page