|
@@ -1,11 +1,36 @@
|
|
|
-#!/usr/bin/python
|
|
|
+#! /usr/bin/env python
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+# vim: set ft=python ts=4 sw=4 sts=4 et :
|
|
|
|
|
|
-from gi.repository import Gio
|
|
|
import sys
|
|
|
+import subprocess
|
|
|
+
|
|
|
+from gi.repository import Gio
|
|
|
|
|
|
def main(myname, desktop, *files):
|
|
|
- launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
|
|
|
- launcher.launch(files, None)
|
|
|
+ info = Gio.DesktopAppInfo()
|
|
|
+ dbus_activate = False
|
|
|
+
|
|
|
+ try:
|
|
|
+ launcher = info.new_from_filename(desktop)
|
|
|
+ except TypeError:
|
|
|
+ launcher = None
|
|
|
+
|
|
|
+ if launcher:
|
|
|
+ try:
|
|
|
+ dbus_activate = launcher.get_boolean('DBusActivatable')
|
|
|
+ except AttributeError:
|
|
|
+ dbus_activate = False
|
|
|
+
|
|
|
+ if not dbus_activate:
|
|
|
+ launcher.launch(files, None)
|
|
|
+
|
|
|
+ else:
|
|
|
+ if dbus_activate:
|
|
|
+ cmd = ['gapplication', 'launch', launcher.get_id().replace('.desktop', '')]
|
|
|
+ if files:
|
|
|
+ cmd.extend(files)
|
|
|
+ process = subprocess.Popen(cmd, close_fds=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main(*sys.argv)
|