-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Xfce #311
Comments
I've done some testing and here are results. org.Xfce.Session.Manager.Inhibit
org.freedesktop.PowerManagement.Inhibit
org.xfce.PowerManager
org.freedesktop.login1.Manager.Inhibit
Test 1
Test 1 detailsfrom jeepney import DBusAddress, new_method_call
from jeepney.io.blocking import open_dbus_connection
from jeepney.wrappers import unwrap_msg
addr = DBusAddress(
object_path='/org/freedesktop/login1',
bus_name='org.freedesktop.login1',
interface='org.freedesktop.login1.Manager',
)
msg = new_method_call(
addr,
method='Inhibit',
signature='ssss',
body=('sleep', 'wakepy', 'wakelock active', 'block'),
)
connection = open_dbus_connection(bus="SYSTEM", enable_fds=True)
reply = connection.send_and_get_reply(msg, timeout=2)
resp = unwrap_msg(reply)
fd = resp[0] Running this with
But this did not prevent automatic suspend Test 2
CodeSome pieces of code for possible use in the futureorg.freedesktop.login1 class FreedesktopLogin1Inhibit(Method):
"""Method using org.freedesktop.login1.Manager.Inhibit D-Bus API
References:
[1]: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.login1.html
[2]: https://systemd.io/INHIBITOR_LOCKS/
"""
name = "org.freedesktop.login1"
mode_name = ModeName.KEEP_RUNNING
login1_manager = DBusAddress(
bus=BusType.SYSTEM,
service="org.freedesktop.login1",
path="/org/freedesktop/login1",
interface="org.freedesktop.login1.Manager",
)
# Note: There is no "UnInhibit" method. The method returns a file
# descriptor. The lock is released the moment this file descriptor and all
# its duplicates are closed.
method_inhibit = DBusMethod(
name="Inhibit",
signature="ssss",
params=("what", "who", "why", "mode"),
output_signature="h",
output_params=("fd",),
).of(login1_manager)
supported_platforms = (PlatformType.UNIX_LIKE_FOSS,)
def enter_mode(self) -> None:
# The method arguments are:
# what (str):
# Colon-separated list of lock types: shutdown, sleep, idle,
# handle-power-key, handle-suspend-key, handle-hibernate-key
# and handle-lid-switch. The ones interesting for wakepy are "sleep"
# and "idle".
# who (str)
# The name of the application requesting the lock.
# why (str):
# The reason for requesting the lock.
# mode (str):
# The lock mode. Either "block" or "delay".
call = DBusMethodCall(
method=self.method_inhibit,
args=dict(
what="sleep",
who="wakepy",
why="wakelock active",
mode="block",
),
)
retval = self.process_dbus_call(call)
if retval is None:
raise RuntimeError(
"Could not get file handle from org.freedesktop.login1"
)
self.inhibit_cookie = retval[0] lower-level alternative: from jeepney import DBusAddress, new_method_call
from jeepney.io.blocking import open_dbus_connection
from jeepney.wrappers import unwrap_msg
addr = DBusAddress(
object_path='/org/freedesktop/login1',
bus_name='org.freedesktop.login1',
interface='org.freedesktop.login1.Manager',
)
msg = new_method_call(
addr,
method='Inhibit',
signature='ssss',
body=('sleep', 'wakepy', 'wakelock active', 'block'),
)
connection = open_dbus_connection(bus="SYSTEM", enable_fds=True)
reply = connection.send_and_get_reply(msg, timeout=2)
resp = unwrap_msg(reply)
fd = resp[0] org.xfce.PowerManager class XfcePowerManagerInhibit(FreedesktopInhibitorWithCookieMethod):
name = "org.xfce.PowerManager"
mode_name = ModeName.KEEP_RUNNING
service_dbus_address = DBusAddress(
bus=BusType.SESSION,
service="org.xfce.PowerManager",
path="/org/freedesktop/PowerManagement/Inhibit",
interface="org.freedesktop.PowerManagement.Inhibit",
) |
As none of the above methods are suitable for just the keep.running method (without sudo), I'm not sure what to do. I asked on the xfce forums some advice. Perhaps there's still some other way to prevent automatic suspending on Xcfe < 4.19. |
One possible alternative could be to use the |
Different methods on xfce:
org.Xfce.Session.Manager.Inhibit
/org/xfce/SessionManager
org.xfce.Session.Manager
Inhibit
, with parameters app_id (str), toplevel_xid (int), reason (str), flags (int) and return value inhibit_cookie (int)org.freedesktop.PowerManagement.Inhibit
org.freedesktop.PowerManagement.Inhibit
inhibits also screensaver: https://gitlab.xfce.org/xfce/xfce4-power-manager/-/issues/65org.freedesktop.PowerManagement
(on Session bus)/org/freedesktop/PowerManagement/Inhibit
org.freedesktop.PowerManagement.Inhibit
Inhibit
, with parameters application_name (str) and reason (str) and return value inhibit_cookie (int). Note that since this does not have input parameter "flags", you may not control what this inhibits, and there are two kinds of behaviors found in the wild (keep.running (=the correct one?) and keep.presenting).org.freedesktop.login1.Manager.Inhibit
org.freedesktop.login1
/org/freedesktop/login1
org.freedesktop.login1.Manager
Inhibit
, with parameters what (str) who (str) why (str) mode (str) and return value file_descriptor (File Descriptor).org.xfce.PowerManager
org.xfce.PowerManager
/org/freedesktop/PowerManagement/Inhibit
org.freedesktop.PowerManagement.Inhibit
Inhibit
, with parameters application_name (str) and reason (str) and return value inhibit_cookie (int).Notes
The text was updated successfully, but these errors were encountered: