
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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.
$ pip install eugeroic
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):
...
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.
FAQs
Prevent your computer from sleeping
We found that eugeroic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.