2015-08-07 13:50:56 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: set ft=python ts=4 sw=4 sts=4 et :
|
2014-10-27 12:25:45 +01:00
|
|
|
|
|
|
|
import sys
|
2015-08-07 13:50:56 +02:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
from gi.repository import Gio
|
2014-10-27 12:25:45 +01:00
|
|
|
|
|
|
|
def main(myname, desktop, *files):
|
2015-08-07 13:50:56 +02:00
|
|
|
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)
|
2014-10-27 12:25:45 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main(*sys.argv)
|