Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-09-23 12:14:29

fohrloop
Member
Registered: 2024-09-23
Posts: 2

Preventing automatic suspend on Xfce<4.19 programmatically?

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

  1. Not also prevent screen lock or screen saver); just the suspend

  2. Not require sudo

  3. 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).

org.Xfce.Session.Manager
  • Added here. Seems to be the correct solution but does not exists yet in Xfce 4.18.

org.freedesktop.PowerManagement.Inhibit
  • 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.

org.xfce.PowerManager
  • Seems to be just a proxy / alias for org.freedesktop.PowerManagement.Inhibit

org.freedesktop.login1.Manager.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

#2 2024-09-24 00:16:54

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,369

Re: Preventing automatic suspend on Xfce<4.19 programmatically?

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

#3 2024-09-24 07:03:02

fohrloop
Member
Registered: 2024-09-23
Posts: 2

Re: Preventing automatic suspend on Xfce<4.19 programmatically?

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

Registered users online in this topic: 0, guests: 1
[Bot] CCBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 8 queries executed - Memory usage: 528.98 KiB (Peak: 530.27 KiB) ]