#! /bin/bash

###############################################################################
# PackIt v1.14 by SFR'2013-2016                                               #
# GNU GPL v2 applies                                                          #
###############################################################################

APPNAME="PackIt"
MYPATH="$(dirname "$(realpath "$0")")"

export TEXTDOMAINDIR="${MYPATH}/locale"
export TEXTDOMAIN=packit
export OUTPUT_CHARSET=UTF-8

# -----------------------------------------------------------------------------
# Add shortcut on the pinboard (if in use) and/or in $HOME/Desktop/ (if exists)
# -----------------------------------------------------------------------------
if [ -e "$HOME/Choices/ROX-Filer/PuppyPin" ] || [ -d "$HOME/Desktop" ]; then

  [ "`which gxmessage 2>/dev/null`" ] && XMESSAGE=gxmessage || XMESSAGE=xmessage
  $XMESSAGE -buttons "$(gettext 'Yes'):100,$(gettext 'No'):101" -center -title "$APPNAME" "$(gettext 'Create a shortcut on the desktop?')"
  if [ $? -eq 100 ]; then

    [ -e "$HOME/Choices/ROX-Filer/PuppyPin" ] &&
    rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <PinboardAdd>
   <Path>/usr/local/apps/PackIt</Path>
  </PinboardAdd>
 </env:Body>
</env:Envelope>
EOF

    [ -d "$HOME/Desktop" ] && {
    cp -f /usr/share/applications/PackIt.desktop "$HOME/Desktop/PackIt.desktop"
    # Make sure %F is in DOTdesktop's Exec= line
    sed -i 's|Exec=/usr/local/apps/PackIt/AppRun.*|Exec=/usr/local/apps/PackIt/AppRun %F|' "$HOME/Desktop/PackIt.desktop"
    }

  fi
  
fi