File xdg-common-desktop-bin-vendor-dir.patch of Package xdg-utils.openSUSE_13.2_Update
commit 423aad78990024963078b6b775e219487af25cd1
Author: Simon Lees <sflees@suse.de>
Date: Fri May 20 16:27:23 2016 +0930
common: implement vendor dirs in desktop_file_to_binary
Index: xdg-utils-20150119/scripts/xdg-utils-common.in
===================================================================
--- xdg-utils-20150119.orig/scripts/xdg-utils-common.in
+++ xdg-utils-20150119/scripts/xdg-utils-common.in
@@ -50,7 +50,6 @@ binary_to_desktop_file()
#-------------------------------------------------------------
# map a .desktop file to a binary
-## FIXME: handle vendor dir case
desktop_file_to_binary()
{
search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
@@ -58,14 +57,32 @@ desktop_file_to_binary()
IFS=:
for dir in $search; do
unset IFS
- [ "$dir" ] && [ -d "$dir/applications" ] || continue
- file="$dir/applications/$desktop"
- [ -r "$file" ] || continue
- # Remove any arguments (%F, %f, %U, %u, etc.).
- command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
- command="`which "$command"`"
- readlink -f "$command"
- return
+ [ "$dir" ] && [ -d "$dir/applications" ] || [ -d "$dir/applnk" ] || continue
+ # Check if desktop file contains -
+ if [ "${desktop#*-}" != "$desktop" ]; then
+ vendor=${desktop%-*}
+ app=${desktop#*-}
+ if [ -r $dir/applications/$vendor/$app ]; then
+ file_path=$dir/applications/$vendor/$app
+ elif [ -r $dir/applnk/$vendor/$app ]; then
+ file_path=$dir/applnk/$vendor/$app
+ fi
+ else
+ for indir in "$dir"/applications/ "$dir"/applications/*/ "$dir"/applnk/ "$dir"/applnk/*/; do
+ file="$indir/$desktop"
+ if [ -r "$file" ]; then
+ file_path=$file
+ break
+ fi
+ done
+ fi
+ if [ -r "$file_path" ]; then
+ # Remove any arguments (%F, %f, %U, %u, etc.).
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file_path" | cut -d= -f 2- | first_word`"
+ command="`which "$command"`"
+ readlink -f "$command"
+ return
+ fi
done
}