fohrloop / wakepy

Cross-platform keep-awake with python
MIT License
195 stars 14 forks source link

Method using gtk_application_inhibit() #407

Open fohrloop opened 2 months ago

fohrloop commented 2 months ago

Aims to close: #404

Add support for unix systems with GTK

Details

TODO

fohrloop commented 1 month ago

I have now a working implementation which still requires some refactoring + tests, but here are some timings. It can run in two modes:

Timings

Here are some timings for doing one inhibit -> uninhibit cycle:

Code used for benchmarking ```python import time import logging logging.basicConfig(level=logging.DEBUG) from wakepy import keep t0 = time.time() with keep.presenting(methods=['gtk_application_inhibit']) as m: ... t1 = time.time() print(t1-t0) ```

Using local gi module:

# first run
DEBUG:wakepy.core.mode:'WAKEPY_FAKE_SUCCESS' not set.
DEBUG:wakepy.pyinhibitor.inhibitors:Inhibitor module 'wakepy.methods.gtk.inhibitor' loaded to local python environment
DEBUG:wakepy.methods.gtk.inhibitor:Registering Gtk.Application with id  io.readthedocs.wakepy.inhibitor1
DEBUG:wakepy.methods.gtk.inhibitor:Registered Gtk.Application with id  io.readthedocs.wakepy.inhibitor1
0.1985936164855957

# second run
DEBUG:wakepy.core.mode:'WAKEPY_FAKE_SUCCESS' not set.
DEBUG:wakepy.pyinhibitor.inhibitors:Inhibitor module 'wakepy.methods.gtk.inhibitor' loaded to local python environment
DEBUG:wakepy.methods.gtk.inhibitor:Registering Gtk.Application with id  io.readthedocs.wakepy.inhibitor2
DEBUG:wakepy.methods.gtk.inhibitor:Registered Gtk.Application with id  io.readthedocs.wakepy.inhibitor2
0.0038368701934814453

Using the subprocess:

DEBUG:wakepy.core.mode:'WAKEPY_FAKE_SUCCESS' not set.
DEBUG:wakepy.pyinhibitor.inhibitors:Inhibitor module "wakepy.methods.gtk.inhibitor" not found in the current python environment. Trying to use "/usr/bin/python" instead.
DEBUG:wakepy.pyinhibitor.inhibitors:Response from pyinhibit server: INHIBIT_OK
Received request: QUIT
DEBUG:wakepy.pyinhibitor.inhibitors:Response from pyinhibit server: UNINHIBIT_OK
0.22979283332824707
fohrloop commented 1 month ago

I'm leaving this one open. I'm working on other projects and I don't have this top of my priority list. Coming back to this later, whenever I have spare time for a new release :)