# Function to find the real directory a program resides in.
# Feb. 17, 2000 - Sam Lantinga, Loki Entertainment Software
fullpath="`echo $1 | grep /`"
if [ "$fullpath" = "" ]; then
do if [ -x "$path/$1" ]; then
if [ "$path" = "" ]; then
if [ "$fullpath" = "" ]; then
# Is the sed/ls magic portable?
if [ -L "$fullpath" ]; then
#fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
fullpath=`ls -l "$fullpath" |sed -e 's/.* -> //' |sed -e 's/\*//'`
# Set the home if not already set.
if [ "${VELNEO_PATH}" = "" ]; then
VELNEO_PATH="`FindPath $0`"
LD_LIBRARY_PATH=.:${VELNEO_PATH}:${LD_LIBRARY_PATH}
# Creamos acceso directo para vClient que además gestiona los esquemas vatp y vatps
MENU_USUARIO=$HOME/.local/share/applications
FICHERO_ACCESO="$MENU_USUARIO/com.velneo.$COMPONENTE.desktop"
# Comprobamos que no exista ya el acceso directo
# Comprobamos que xdg-open está instalado
if [ ! -e "$FICHERO_ACCESO" ] && xdg-open --version >/dev/null 2>&1; then
# Creamos el acceso directo y asociamos los esquemas vatp y vatps
echo ____________________________________________
echo "Creamos los accesos directos en el menú"
VELNEO_PATH_REAL=$(realpath "${VELNEO_PATH}" )
chmod +x "$FICHERO_ACCESO"
echo "Name=Velneo $COMPONENTE"
echo "GenericName=Componente de Velneo"
echo "Comment=Velneo $COMPONENTE es un componente de Velneo"
echo "Exec=${VELNEO_PATH_REAL}/$COMPONENTE.sh %u"
echo "Icon=${VELNEO_PATH_REAL}/$COMPONENTE.png"
echo "Categories=Qt;Development;"
echo "MimeType=application/x-velneo;x-scheme-handler/vatps;x-scheme-handler/vatp;"
echo "Registramos el acceso directo vClient y los protocolos vatp y vatps"
xdg-mime default "com.velneo.$COMPONENTE.desktop" x-scheme-handler/vatps
xdg-mime default "com.velneo.$COMPONENTE.desktop" x-scheme-handler/vatp
echo ____________________________________________
echo "Registramos los accesos directos creados para el menú"
echo ============================================
update-desktop-database "$MENU_USUARIO"