wakepy icon indicating copy to clipboard operation
wakepy copied to clipboard

Method using gtk_application_inhibit()?

Open fohrloop opened this issue 5 months ago • 4 comments

See: https://docs.gtk.org/gtk3/method.Application.inhibit.html

If I'm not mistaken, this requires PyGObject (which has import name gi) . It could be used as an alternative "no dbus" option?

This is a particularly interesting option since so many Desktop Environments are based on the GTK graphical toolkit (GNOME, Xfce, Cinnamon, LXDE, MATE, Unity, Budgie, Pantheon), and because it offers a non-dbus alternative.

Alternatives

  1. Make PyGObject (gi) a requirement for wakepy. This has the downside that (1) It's an additional dependency and (2) the PyGObject is not pure python package so it requires compiling tools to be available.

  2. ~Do site-packages search for system python folder and add the gi package into the sys.path~ Use system python in separate process. I'm assuming that gi python package is available in all the desktop environments which use GTK. No additional dependencies would be needed for wakepy. In other words, the gi python package would be treated as any non-python dependency; you search, and if you find, you can use.

  3. Interfacing gtk_application_inhibit() directly without gi somehow. Does not require dependency but probably requires a lot of extra work. I assume that if a system has GTK, it has also gi python package available so this kind extension module is not required.

Tasks

  • [x] Try out gtk_application_inhibit() with gi. Is it possible to prevent sleep and/or idle with it (to support both: keep.running and keep.presenting modes)? yes, it is.
  • [ ] Find a way to get the system site-packages location reliably

fohrloop avatar Sep 22 '24 17:09 fohrloop