summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRex Dieter <rdieter@math.unl.edu>2017-02-28 09:02:38 -0600
committerRex Dieter <rdieter@math.unl.edu>2017-02-28 09:02:38 -0600
commit7836138fe83d7ac94a711d51038ebf456069e161 (patch)
tree1fde86c524427c60ca9793a0fbd475b2e5f2c5be
parent1f8e58d51e6fb3f50f59ed2d8265f2f346ac68e6 (diff)
common: implement vendor dirs in desktop_file_to_binary (BR44163)
-rw-r--r--scripts/xdg-utils-common.in36
1 files changed, 27 insertions, 9 deletions
diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in
index f4b7561..05fa06d 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,33 @@ 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
+ fi
+ if test -z "$file_path" ; then
+ 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
}