A discussion came up with VDR experts (hey, these guys are also very experienced) when I was trying to configure my Video Disk Recorder PC also to be useable as a Desktop PC using KDE. The idea is to have the PC being controlled by VDR and the user. To avoid that the PCs gets shut down by the desktop when a recording is active by VDR, the VDR process should set an inhibitor that is avoiding the shutdown and the Desktop is recognizing this, not requesting a shutdown. Logind / system-dbus provide the needed infrastructure with inhibitors for that. The todays behaviour is, that the user will be prompted for a password in both cases. While this is ok when the shutdown was triggered by the user, an inactivity timeout should not open a popup. There I would expect that the desktop waits until the inhibitor has been closed. Reproducible: Always Steps to Reproduce: 1. Set an inhibitor from another user. I used the added python program for that. 2. Wait until the the desktop wants to suspend due to inactivity. Configure PowerDevil accordingly. Actual Results: A dialog pops up asking for confirmation even that there is likely no user as the session timed out and a suspend is triggered. Expected Results: Power Devil should wait until the inhibitor has been removed. Then a shutdown should beeing triggered. As an alternative there should be an timeout for the password prompt a retry to suspend after some time. This is the program I used to set the inhibitor. Run it from another user and then try to suspend the machine from the session user. In any case the sleep will be rejected. #!/usr/bin/python3 import dbus import logging import time bus = dbus.SystemBus() def inhibit(what='sleep', who='First Base', why="left field", mode="block"): try: a = bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1') interface = 'org.freedesktop.login1.Manager' print("Inhibitor opened: what = {}, mode = {}".format(what, mode)) fd = a.Inhibit(what, who, why, mode, dbus_interface=interface) return fd except Exception as error: logging.exception(error) logging.warning("could not set inhibitor lock") if __name__ == '__main__': my_inhibitor_fd = inhibit() #input('press any key to exit inhibitor') inhibitTime = 1200 print("Suspend inhibitor will be active for {} seconds".format(inhibitTime)) time.sleep(inhibitTime)
PowerDevil currently doesn't handle Logind inhibitions at all unfortunately. This is on my agenda at somwhere but I'm not really into changing all of this yet again. At least for idle and sleep inhibitions PowerDevil might get support at some point. CC'ing David who recently looked into Logind and PowerDevil. At the moment the only truly supported inhibition is to call freedesktop inhibition on the currently active session.
Thx for the fast reply. Unfortunately this is only usable by processes that run in the same session. For a daemon running with another user in an own session context the solution should automatically recognize all sessions by using directly system dbus. Also the authentication will be bad using session bus from a daemon. I will try to workaround and give the call of the freedesktop inhibition a try. Perhaps I am able to create a gateway service.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/30
Git commit b5dfb286a4d9b43ac74862218beb5dd7f58ea7a8 by Kai Uwe Broulik. Committed on 18/12/2020 at 14:40. Pushed by broulik into branch 'master'. Take into account logind sleep and idle inhibitions System services cannot access the user's session bus and that freedesktop inhibition interface appears deprecated. This patch makes PowerDevil watch logind's BlockInhibited property and internally posts an appropriate inhibition. FIXED-IN: 5.21.0 M +106 -0 daemon/powerdevilpolicyagent.cpp M +22 -0 daemon/powerdevilpolicyagent.h https://invent.kde.org/plasma/powerdevil/commit/b5dfb286a4d9b43ac74862218beb5dd7f58ea7a8