1#!/bin/bash
2
3# The purpose of this custom AppRun script is
4# to allow symlinking the AppImage and invoking
5# the corresponding binary depending on which
6# symlink was used to invoke the AppImage
7
8HERE="$(dirname "$(readlink -f "${0}")")"
9
10export MAGICK_HOME="$HERE/usr:$MAGICK_HOME" # https://imagemagick.org/QuickStart.txt
11export MAGICK_CONFIGURE_PATH=$(readlink -f "$HERE/usr/lib/ImageMagick-7.0.9/config-Q16"):$(readlink -f "$HERE/usr/lib/ImageMagick-7.0.9/config-Q16HDRI"):$(readlink -f "$HERE/usr/share/ImageMagick-7"):$(readlink -f "$HERE/usr/etc/ImageMagick-7"):$MAGICK_CONFIGURE_PATH #Wildcards don't work
12
13export LD_LIBRARY_PATH=$(readlink -f "$HERE/usr/lib"):$LD_LIBRARY_PATH
14export LD_LIBRARY_PATH=${HERE}/usr/lib/ImageMagick-7.0.9/modules-Q16HDRI/coders:$LD_LIBRARY_PATH
15
16if [ "$1" == "man" ] ; then
17  export MANPATH="$HERE/usr/share/man:$MANPATH" ; exec "$@" ; exit $?
18elif [ "$1" == "info" ] ; then
19  export INFOPATH="$HERE/usr/share/info:$INFOPATH" ; exec "$@" ; exit $?
20fi
21
22if [ ! -z $APPIMAGE ] ; then
23  BINARY_NAME=$(basename "$ARGV0")
24  if [ -e "$HERE/usr/bin/$BINARY_NAME" ] ; then
25    exec "$HERE/usr/bin/$BINARY_NAME" "$@"
26  else
27    exec "$HERE/usr/bin/magick" "$@"
28  fi
29else
30  exec "$HERE/usr/bin/magick" "$@"
31fi
32