Open fohrloop opened 2 months ago
I have now a working implementation which still requires some refactoring + tests, but here are some timings. It can run in two modes:
gi
(PyGObject) is installed to the current python environment, that is used.gi
is not installed to current python environment, but is available to system python, that is used.Here are some timings for doing one inhibit -> uninhibit cycle:
from gi.repository import Gio, Gtk
.
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
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 :)
Aims to close: #404
Add support for unix systems with GTK
PyGObject
(gi
) python library installed either on the current python environment or the system python site packages.Details
gi
, package name:PyGObject
) for inhibiting sleep/idle. This is the PyGObject interface to the gtk_application_inhibit() function.gi
module for accessing GTK functions from python. User is not required to have installed the in their current (virtual) environment. It's just faster to use (300ms vs 5ms) ifgi
is available in the current python environment. Most people probably won't care if their long running script takes a 300ms more, and not having to install PyGObject is a nice thing as the installation will require compilation step(s), so it's a bit trickier and slower to install than a pure python package.Inhibitor
, which should comply with the new Inhibitor protocol: There must be astart(self, *args)
andstop(self)
methods. The*args
are positional arguments given to the server and passed to the inhibitor.TODO