Socket
Socket
Sign inDemoInstall

eugeroic

Package Overview
Dependencies
12
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eugeroic

Prevent your computer from sleeping


Maintainers
1

Readme

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.

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc