Skip to main content

Prevent your computer from sleeping

Project description

Eugeroic

Tools in Python for keeping a computer display awake.

eugeroic : (adjective) keeping one awake. Of a wakefulness promoting agent.

Sometimes you need to perform a task without the screensaver kicking in, or the display being suspended entirely. This may be because you are capturing the screen, or because you are running presentation software, or because you are running a long-running task that you want to monitor without interaction. This module provides a context manager and a decorator that can be used to keep the display awake while the block or function is running.

Installation

$ pip install eugeroic

Examples

The wakefulness context manager keeps the computer awake while the block is running:

# Keep the computer awake while capturing the screen.

from eugeroic import wakefulness

with wakefulness("Capture the screen"):
    capture_screen(seconds=500)

The stay_awake decorator keeps the computer awake while the decorated function is running:

# Keep the computer awake while capturing the screen.

from eugeroic import stay_awake

@stay_awake("Capture the screen")
def capture_screen(seconds):
    ...

How it works

On Windows calls to SetThreadExecutionState are used.

On macOS IOKit Power Management functions are used.

On Linux, an attempt is made to communicate with the desktop environment through D-Bus messages.

Note that while every attempt is made to keep the computer and display awake, there is no guarantee that the display will not be suspended. For example, on macOS, the display will be suspended if the user locks the screen. On Linux, the display will be suspended if the user switches to a different virtual terminal. On Windows, the display will be suspended if the user locks the screen or switches to a different user account. In particular, on Linux, there is no guarantee that the required D-Bus messages will be handled by the desktop environment. In practice though, Eugeroic usually works.

MIT License

Copyright (c) 2023 Sixty North AS

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

eugeroic-1.8.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

eugeroic-1.8.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file eugeroic-1.8.2.tar.gz.

File metadata

  • Download URL: eugeroic-1.8.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for eugeroic-1.8.2.tar.gz
Algorithm Hash digest
SHA256 732480a5d4770d5ea55b53264138f3346fdc0db6b79c61163f21ea4f63c3251f
MD5 367e9ed8c2f498771bf0ebe3977fb3d6
BLAKE2b-256 d55af165526b2c3798d2d710477a071834f9dfa19e66500e97a7d75c93b7fbc4

See more details on using hashes here.

File details

Details for the file eugeroic-1.8.2-py3-none-any.whl.

File metadata

  • Download URL: eugeroic-1.8.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for eugeroic-1.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ebbaff264f5a36af4819f4577c7f49d690062eacf85d5bb9e4b056056b0d51
MD5 bd7d3a4a9fd19248e436116d0bd7f8c6
BLAKE2b-256 ee68262d45ea9eda2a8043c16eb7462258cae18272f14ccbe3792379fc0a74e0

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