#!/bin/sh
# XXTH 2024-01-25
#
# * create and install an Menu-Entry (Icon) for your Application
# * create a removeIcon.sh script to remove it again
# your Application variables:
APPNAME="Auteria"
EXE="auteria"
VERSION="2.30"
COMMENT="Auteria https://auteria.com"
# relative path to this script.
ICON="AuteriaIcon256.png"
# multipe Categories are separated with semicolons example: Game;Simulation
CATEGORIES="Game"
#------------------------------------------------------------------------------
# move to current directory
CURPATH=`dirname "{CONTENT}"`
cd $CURPATH
GAMEPATH=`pwd`
DESKTOP_MODE="user"
ICON_SIZE="48"
DESKTOPFILE=$APPNAME.desktop
FILENAME="$GAMEPATH/$DESKTOPFILE"
ICONFILE="$GAMEPATH/$ICON"
MENUCMD=`command -v xdg-desktop-menu`
DESKTOPPATH=$( eval echo "~/Desktop/" )
# create desktop file:
echo "[Desktop Entry]" > $FILENAME
echo "Version=$VERSION" >> $FILENAME
echo "Type=Application" >> $FILENAME
echo "Name=$APPNAME" >> $FILENAME
echo "Comment=$COMMENT" >> $FILENAME
echo "Exec=$GAMEPATH/$EXE" >> $FILENAME
echo "Icon=$ICONFILE" >> $FILENAME
echo "Path=$GAMEPATH" >> $FILENAME
echo "Terminal=false" >> $FILENAME
echo "Categories=$CATEGORIES" >> $FILENAME
echo "StartupNotify=false" >> $FILENAME
# check if we can do anything
if [ ! -d $DESKTOPPATH ] && [ "$MENUCMD" = "" ]; then
echo "---------------------------------------"
echo "CreateIcon failed!"
echo "! Command xdg-desktop-menu not found. "
echo "! $DESKTOPPATH does not exists."
echo "* but $FILENAME created, you can copy it manually on your Desktop."
echo "---------------------------------------"
exit 1
fi
#register in menu
if [ "$MENUCMD" != "" ]; then
$MENUCMD install --novendor --mode $DESKTOP_MODE $FILENAME
fi
# add to desktop
if [ -d $DESKTOPPATH ]; then
cp $FILENAME $DESKTOPPATH
fi
#write removeIcon
REMOVEICONSCRIPT="$CURPATH/removeIcon.sh"
echo "#!/bin/sh" > $REMOVEICONSCRIPT
if [ "$MENUCMD" != "" ]; then
echo "$MENUCMD uninstall --novendor --mode $DESKTOP_MODE $DESKTOPFILE" >> $REMOVEICONSCRIPT
fi
if [ -d $DESKTOPPATH ]; then
echo "rm $DESKTOPPATH/$DESKTOPFILE" >> $REMOVEICONSCRIPT
fi
chmod 755 $REMOVEICONSCRIPT
echo "---------------------------------------"
echo "CreateIcon finished..."
echo "* desktop file: $FILENAME created"
if [ "$MENUCMD" != "" ]; then
echo "* added $DESKTOPFILE to your menu in Categories: $CATEGORIES"
fi
if [ -d $DESKTOPPATH ]; then
echo "* added $DESKTOPFILE to your Desktop ($DESKTOPPATH)"
fi
echo "* created $REMOVEICONSCRIPT, if you want to remove the icon"
echo "---------------------------------------"