JAL-3830 first draft of wrapper script to go in macOS Jalview.app/Contents/MacOS...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 10 Mar 2021 19:50:34 +0000 (19:50 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 10 Mar 2021 19:50:34 +0000 (19:50 +0000)
utils/install4j/macos_jalview [new file with mode: 0755]

diff --git a/utils/install4j/macos_jalview b/utils/install4j/macos_jalview
new file mode 100755 (executable)
index 0000000..771d15b
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+ARG1=$1
+WDIR="$( pwd )"
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+APP=${DIR%/Contents/MacOS}
+
+if [ "${APP}" = "${APP%.app}" ]; then
+  echo "Could not find .app dir" >&2
+  exit 1
+fi
+
+# check to see if $1 is set and is not start of other cli set args
+OPEN=""
+if [ -n "$ARG1" -a "$ARG1" = "${ARG1#-}" ]; then
+ # first argument exists and does not start with a "-"
+ OPEN="-open"
+fi
+
+# This would open the Jalview application as if double clicking, with the supplied args
+# open -a ${APP} --args $OPEN "$@"
+### or...
+
+APPDIR=${APP}/Contents/Resources/app
+JAVA=${APPDIR}/jre/Contents/Home/bin/java
+CLASSPATH=""; for x in $(grep -e 'code = ' ${APP}/Contents/Resources/app/getdown.txt | sed -e 's/^code = //;'); do [ -n "$CLASSPATH" ] && CLASSPATH="${CLASSPATH}:"; CLASSPATH="${CLASSPATH}${APPDIR}/${x}"; done
+
+#TODO add a -workingdir DIR argument for jalview.bin.Jalview to set user.dir. This will fix JAL-3523
+echo $JAVA -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@"
+$JAVA -cp "$CLASSPATH" jalview.bin.Launcher $OPEN "$@"
+# -workingdir "$WDIR"