core-agent-linux/misc/qubesxdg.py
MB 3339df739d
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)
2017-12-20 20:56:29 +01:00

28 lines
808 B
Python
Executable File

#!/usr/bin/python
from gi.repository import Gio
import sys
def launch(desktop, *files):
launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
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__":
launch(*sys.argv[1:])