2015-08-27 20:08:33 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from gi.repository import Gio
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def launch(desktop, *files):
|
|
|
|
launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
|
2017-12-16 19:45:10 +01:00
|
|
|
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
|
2015-08-27 20:08:33 +02:00
|
|
|
launcher.launch(files, None)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
launch(*sys.argv[1:])
|