X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fgetdown%2Fbin%2Fjalview.sh;h=371bfcd4f50215f58467de0a30e21d9b4d707855;hb=42e022a59de649375c8878c1d26361cb6bc89cb8;hp=62da28c0b8058720fa1fc620c7f27d5d19ad62d6;hpb=51909770452369f94b4a0070482ab0acdd96fada;p=jalview.git diff --git a/utils/getdown/bin/jalview.sh b/utils/getdown/bin/jalview.sh index 62da28c..371bfcd 100755 --- a/utils/getdown/bin/jalview.sh +++ b/utils/getdown/bin/jalview.sh @@ -36,18 +36,47 @@ if [ "$( uname -s )" = "Darwin" ]; then ISMACOS=1 fi +# check for headless mode +HEADLESS=0 +GUI=0 +HELP=0 +DEBUG=0 +for ARG in "${@}"; do + case "${ARG}" in + "--headless") + HEADLESS=1 + ;; + "--help") + HELP=1 + ;; + --help-*) + HELP=1 + ;; + "--gui") + GUI=1 + ;; + "--debug") + DEBUG=1 + ;; + esac + + if [ "${HELP}" = 1 ]; then + # --help takes precedence + HEADLESS=1 + GUI=0 + elif [ "${GUI}" = 1 ]; then + # --gui takes precedence over --headless + HEADLESS=0 + fi +done + declare -a JVMARGS=() # set vars for being inside the macos App Bundle if [ "${ISMACOS}" = 1 ]; then # MACOS ONLY DIR="$(dirname "$(readlinkf "$0")")" - APP="${DIR%.app/Contents/*}".app - if [ "${APP}" = "${APP%.app}" ]; then - echo "Could not find Jalview.app" >&2 - exit 2 - fi - APPDIR="${APP}/Contents/Resources/app" + APPDIR="${DIR%/bin}" JAVA="${APPDIR}/jre/Contents/Home/bin/java" JVMARGS=( "${JVMARGS[@]}" "-Xdock:icon=${APPDIR}/resource/jalview_logo.png" ) else @@ -57,6 +86,11 @@ else JAVA="${APPDIR}/jre/bin/java" fi +if [ "${HEADLESS}" = 1 ]; then + # this suppresses the Java icon appearing in the macOS Dock and maybe other things in other OSes + JVMARGS=( "${JVMARGS[@]}" "-Djava.awt.headless=true" ) +fi + SYSJAVA=java GETDOWNTXT="${APPDIR}/getdown.txt" @@ -65,7 +99,8 @@ CLASSPATH="" declare -a JARPATHS=() if [ -e "${GETDOWNTXT}" ]; then # always check grep and sed regexes on macos -- they're not the same - for JAR in $(grep -e '^code\s*=\s*' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do +for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done); + do [ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:" CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}" JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" ) @@ -122,6 +157,7 @@ elif command -v resize 2>&1 >/dev/null; then COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null fi JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" ) +JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" ) # Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL) if [ \! -e "${JAVA}" ]; then @@ -129,4 +165,8 @@ if [ \! -e "${JAVA}" ]; then echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2 fi +if [ "${DEBUG}" = 1 ]; then + echo Shell running: \""${JAVA}"\" \""${JVMARGS[@]}"\" -cp \""${CLASSPATH}"\" jalview.bin.Launcher "${ARGS[@]}" +fi + "${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"