Coder Social home page Coder Social logo

kolanich-libs / nosuspend.py Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 16 KB

A library to prevent the system from entering powersaving mode. !!! Migrated to Codeberg ๐Ÿ”๏ธ !!!

Home Page: https://codeberg.org/KOLANICH-libs/NoSuspend.py

License: The Unlicense

Python 100.00%
power management acpi s1 s2 s3 s4 suspend sleep hibernation

nosuspend.py's Introduction

NoSuspend.py Unlicensed work

wheel (GitLab) wheel (GHA via nightly.link) GitLab Build Status GitLab Coverage GitHub Actions Libraries.io Status Code style: antiflash

We have moved to https://codeberg.org/KOLANICH-libs/NoSuspend.py, grab new versions there.

Under the disguise of "better security" Micro$oft-owned GitHub has discriminated users of 1FA passwords while having commercial interest in success and wide adoption of FIDO 1FA specifications and Windows Hello implementation which it promotes as a replacement for passwords. It will result in dire consequencies and is competely inacceptable, read why.

If you don't want to participate in harming yourself, it is recommended to follow the lead and migrate somewhere away of GitHub and Micro$oft. Here is the list of alternatives and rationales to do it. If they delete the discussion, there are certain well-known places where you can get a copy of it. Read why you should also leave GitHub.


This is a library to prevent the system from entering powersaving mode such as ACPI S1-4.

Requirements

  • For Linux you need python3-dbus and some programms providing the used D-Bus interfaces.

Tutorial

  • A very basic cross-platform way.
  • Import the lib:
from NoSuspend import *
  • Use the context manager:
with NoSuspend():
	doLongWork()
  • You can provide additional arguments depending on platform:

  • on Windows you can provide additional parameters, for example to keep the screen enabled

with NoSuspend(suspend=True, display=True, hidden=False, inherit=True):
	doLongWork()
  • on Linux (with desktop environment) you can provide your application name and the reason
with NoSuspend(suspend=True, display=False, hidden=False, appName="MySuperApp", reason="doing long work..."):
	doLongWork()
  • You can retrieve the state when used context manager:
with NoSuspend() as state:
	print(state)

on Windows you can just retrieve it using

print(NoSuspend.getCurrentState())
  • The state is nested, the default state on Windows is EXECUTION_STATE.CONTINUOUS | EXECUTION_STATE.SYSTEM_REQUIRED ( coresponds to suspend=True ) as expected. There are 2 inherit modes:
print(NoSuspend.getCurrentState())
with NoSuspend() as state1:
	print(state1, NoSuspend.getCurrentState())
	with NoSuspend(display=True, inherit=False) as state2: # the default one, replaces the state
		print(state2, NoSuspend.getCurrentState())
	print(NoSuspend.getCurrentState())
print(NoSuspend.getCurrentState())
with NoSuspend() as state1:
	print(state1, NoSuspend.getCurrentState())
	with NoSuspend(EXECUTION_STATE.DISPLAY_REQUIRED, inherit=True) as state2: # adds flags to the state
		print(state2, NoSuspend.getCurrentState())
	print(NoSuspend.getCurrentState())

Also a console interface is available

python3 -m NoSuspend echo a
NoSuspend echo a
caffeinate echo a

nosuspend.py's People

Contributors

kolanich avatar

Watchers

 avatar  avatar

nosuspend.py's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.