qubesxdg.py 808 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/python
  2. from gi.repository import Gio
  3. import sys
  4. def launch(desktop, *files):
  5. launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
  6. try:
  7. import dbus
  8. if hasattr(launcher, 'get_boolean'):
  9. activatable = launcher.get_boolean('DBusActivatable')
  10. if activatable:
  11. bus = dbus.SessionBus()
  12. service_id = launcher.get_id()
  13. # cut the .desktop suffix
  14. service_id = service_id[:-8]
  15. try:
  16. bus.start_service_by_name(service_id)
  17. except dbus.DBusException:
  18. pass
  19. return launcher.launch(files, None)
  20. except ImportError:
  21. pass
  22. launcher.launch(files, None)
  23. if __name__ == "__main__":
  24. launch(*sys.argv[1:])