Prechádzať zdrojové kódy

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.
Marek Marczykowski-Górecki 9 rokov pred
rodič
commit
0613a58961
4 zmenil súbory, kde vykonal 15 pridanie a 1 odobranie
  1. 1 0
      Makefile
  2. 11 0
      misc/qubes-desktop-run
  3. 2 1
      qubes-rpc/qubes.GetAppmenus
  4. 1 0
      rpm_spec/core-vm.spec

+ 1 - 0
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

+ 11 - 0
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)

+ 2 - 1
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

+ 1 - 0
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