#!/bin/sh

# this script echos to standard output the directory to install a
# .desktop entry to
#
# it takes one argument, the fallback value
# if no argument given, use /usr/share/applications

# we start with the fallback:
if [ x$1 = x ]; then
	desktopdir=/usr/share/applications
else
	desktopdir=$1
fi

# but try to find a better path in the env variable
for p in `echo $DESKTOP_FILE_PATH | sed 's/:/ /'`; do
	if [ -w $p -a -x $p ]; then
		desktopdir=$p
		break
	fi
done

echo $desktopdir
