You are not logged in.
Hi, I am the author of a python package called wakepy, and I'm in the process of adding support for Xfce. I'm looking for a suitable method for preventing the automatic suspend. The ideal method would
Not also prevent screen lock or screen saver); just the suspend
Not require sudo
Not change any system settings, so that if the application crashes, there should be no need to do any cleanup.
This is what I've found this far. All of these are D-Bus based methods (that's not a requirement).
Added here. Seems to be the correct solution but does not exists yet in Xfce 4.18.
Obsolete spec, but still used in some places
This is present on Xfce 4.18 session bus. Tested and this prevents idle (also prevents screenlock, which many people interpret as a bug. See: xfce4-power-manager/#65 and kde/D11182). This one does not take any arguments so you cannot change what it does.
Seems to be just a proxy / alias for org.freedesktop.PowerManagement.Inhibit
A system bus version which takes also a "what" parameter (sleep or idle)
Tested and it is returning a file descriptor, but holding the fd seems to prevent automatic suspend only if your're running with sudo.
Is there some method that I'm missing (on Xcfe<4.19)?
Offline
Hello and welcome.
Thats a good list of options there. The only other way I can add is enabling Presentation Mode - however that will also prevent the screenlocker. To enable/disable presentation mode you can either find the setting by lift clicking the power manager plugin, or:
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -T
I'm not sure an option exists in Xfce that meets all 3 requirements - the third being the most difficult. You could use xfconf-query to temporarily disable suspend but keep the screenlocker working, but you'd need additional code to manage the settings in the event of a crash of some sort.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Thank you for the answer and the suggestion @ToZ
I have tried to keep system settings untouched as wakepy is a library, and changing system settings might have some nasty side effects. For example, say that some app would be using wakepy, and a user of the app, while using the app (without having a clue about wakepy) goes to his/her system settings and changes something while a wakelock is on. Now, when the app would be quit and wakelock altering system settings would be released, wakepy could change the system settings to be something else than what the user set them to be.
After some digging I bumped into gtk_application_inhibit() which could be a solution if it works. I suppose all systems using GTK come also with the gi (PyGObject) python library installed in the system site-packages, so if I could just reliably find the system python site-packages, I might be able to use it (even if the script/app is running inside a python virtual environment).
Offline
[ Generated in 0.013 seconds, 8 queries executed - Memory usage: 529.06 KiB (Peak: 530.34 KiB) ]