From 3339df739d6f8eac0ae4e787d9d447bf3c8d1859 Mon Sep 17 00:00:00 2001 From: MB Date: Sat, 16 Dec 2017 18:45:10 +0000 Subject: [PATCH] Fall back to direct execution when dbus is not installed or running I have been using this with a dbus-less Gentoo template since the original change, and have tested recently on whonix-gw with dbus enabled and running. (cherry picked from commit bf69335074b45157734b881cc14d54ea43e7902a) --- misc/qubesxdg.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/misc/qubesxdg.py b/misc/qubesxdg.py index 205602f..7e884bf 100755 --- a/misc/qubesxdg.py +++ b/misc/qubesxdg.py @@ -2,18 +2,25 @@ from gi.repository import Gio import sys -import dbus def launch(desktop, *files): launcher = Gio.DesktopAppInfo.new_from_filename(desktop) - if hasattr(launcher, 'get_boolean'): - activatable = launcher.get_boolean('DBusActivatable') - if activatable: - bus = dbus.SessionBus() - service_id = launcher.get_id() - # cut the .desktop suffix - service_id = service_id[:-8] - bus.start_service_by_name(service_id) + try: + import dbus + if hasattr(launcher, 'get_boolean'): + activatable = launcher.get_boolean('DBusActivatable') + if activatable: + bus = dbus.SessionBus() + service_id = launcher.get_id() + # cut the .desktop suffix + service_id = service_id[:-8] + try: + bus.start_service_by_name(service_id) + except dbus.DBusException: + pass + return launcher.launch(files, None) + except ImportError: + pass launcher.launch(files, None) if __name__ == "__main__":