From e66b0d8dfdc7250cd4bcddd6a2445d20acf8c264 Mon Sep 17 00:00:00 2001 From: Colin Gilgenbach Date: Thu, 17 Jan 2019 17:09:57 -0700 Subject: [PATCH] Support for disabling Mate screensaver service --- printrun/power/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/printrun/power/__init__.py b/printrun/power/__init__.py index c34f25300..eebc2e951 100644 --- a/printrun/power/__init__.py +++ b/printrun/power/__init__.py @@ -39,10 +39,16 @@ def deinhibit_sleep(): inhibit_sleep_token = None bus = dbus.SessionBus() try: - # GNOME uses the right object path, try it first - service_name = "org.freedesktop.ScreenSaver" - proxy = bus.get_object(service_name, - "/org/freedesktop/ScreenSaver") + if os.environ.get('DESKTOP_SESSION') == "mate": + # Mate uses a special service + service_name = "org.mate.ScreenSaver" + object_path = "/org/mate/ScreenSaver" + else: + # standard service name + service_name = "org.freedesktop.ScreenSaver" + object_path = "/org/freedesktop/ScreenSaver" + # GNOME and Mate use the right object path, try it first + proxy = bus.get_object(service_name, object_path) inhibit_sleep_handler = dbus.Interface(proxy, service_name) # Do a test run token = inhibit_sleep_handler.Inhibit("printrun", "test")