From 0613a5896179cb2408ae2af274409f5bd7d071e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 27 Oct 2014 12:25:45 +0100 Subject: [PATCH] Improve handling of .desktop files Instead of directly using Exec= line, parse the file (at the launch time) with Gio library. The main reason for this change is to handle Terminal= option, but generally this approach should be more bulletproof, especially when some fancy options are present in desktop files. --- Makefile | 1 + misc/qubes-desktop-run | 11 +++++++++++ qubes-rpc/qubes.GetAppmenus | 3 ++- rpm_spec/core-vm.spec | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 misc/qubes-desktop-run diff --git a/Makefile b/Makefile index 6579547..6096db4 100644 --- a/Makefile +++ b/Makefile @@ -172,6 +172,7 @@ install-common: install -d $(DESTDIR)/usr/share/file-manager/actions install -m 0644 qubes-rpc/*-gnome.desktop $(DESTDIR)/usr/share/file-manager/actions + install -D -m 0755 misc/qubes-desktop-run $(DESTDIR)/usr/bin/qubes-desktop-run install -D misc/nautilus-actions.conf $(DESTDIR)/etc/xdg/nautilus-actions/nautilus-actions.conf install -d $(DESTDIR)/mnt/removable diff --git a/misc/qubes-desktop-run b/misc/qubes-desktop-run new file mode 100755 index 0000000..14e3f8b --- /dev/null +++ b/misc/qubes-desktop-run @@ -0,0 +1,11 @@ +#!/usr/bin/python + +from gi.repository import Gio +import sys + +def main(myname, desktop, *files): + launcher = Gio.DesktopAppInfo.new_from_filename(desktop) + launcher.launch(files, None) + +if __name__ == "__main__": + main(*sys.argv) diff --git a/qubes-rpc/qubes.GetAppmenus b/qubes-rpc/qubes.GetAppmenus index 71e7b33..e26b15b 100644 --- a/qubes-rpc/qubes.GetAppmenus +++ b/qubes-rpc/qubes.GetAppmenus @@ -1 +1,2 @@ -find /usr/share/applications/ /usr/local/share/applications/ -name '*.desktop' | xargs awk '/^\[/ { if (tolower($0) != "\[desktop entry\]") nextfile } /=/ {print FILENAME ":" $0 }' 2> /dev/null +find /usr/share/applications/ /usr/local/share/applications/ -name '*.desktop' | \ + xargs awk '/^\[/ { if (tolower($0) != "\[desktop entry\]") nextfile } /^Exec=/ { print FILENAME ":Exec=qubes-desktop-run " FILENAME; next } /=/ {print FILENAME ":" $0 }' 2> /dev/null diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 7b229d6..43743bf 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -344,6 +344,7 @@ rm -f %{name}-%{version} /usr/bin/qvm-run /usr/bin/qvm-mru-entry /usr/bin/xenstore-watch-qubes +/usr/bin/qubes-desktop-run %dir /usr/lib/qubes /usr/lib/qubes/vusb-ctl.py* /usr/lib/qubes/dispvm-prerun.sh