commit 6e4d88e740b89a2766312fb544e4a22b7034d9e3 Author: Simon Lees Date: Tue May 31 13:13:53 2016 +0930 common: implement vendor dirs in desktop_file_to_binary diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in index cf08cd3..19400a4 100644 --- a/scripts/xdg-utils-common.in +++ b/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 }