From a5ee90b4203d9a7719c2aa3490be51848648648e Mon Sep 17 00:00:00 2001 From: Jason Mehring Date: Fri, 7 Aug 2015 07:50:56 -0400 Subject: [PATCH] qubes-desktop-run: Activate via DBUS when desktop file contains DBusActivatable --- misc/qubes-desktop-run | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/misc/qubes-desktop-run b/misc/qubes-desktop-run index 14e3f8b..a164792 100755 --- a/misc/qubes-desktop-run +++ b/misc/qubes-desktop-run @@ -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 : + +import sys +import subprocess from gi.repository import Gio -import sys 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)