#!/usr/bin/env bash # # Launch script for the "tmpNote" macOS app. # # tmpNote is a menu-bar (LSUIElement) application: when it starts it adds an # icon to the system status bar rather than opening a normal window or showing # a Dock icon. `open -W` keeps this launcher in the foreground until the app is # quit from its menu. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" APP_NAME="tmpNote.app" # Search the likely locations, in order: # 1. $APP_OUTPUT_DIR (where build.sh was told to place the app) # 2. next to this script (build.sh default output) # 3. inside the derived-data build directory produced by build.sh CANDIDATES=( "${APP_OUTPUT_DIR:-$SCRIPT_DIR}/$APP_NAME" "$SCRIPT_DIR/$APP_NAME" "$SCRIPT_DIR/build_dd/Build/Products/Release/$APP_NAME" ) APP_PATH="" for c in "${CANDIDATES[@]}"; do if [ -d "$c" ]; then APP_PATH="$c" break fi done if [ -z "$APP_PATH" ]; then echo "ERROR: could not find $APP_NAME. Run build.sh first." >&2 echo "Looked in:" >&2 printf ' %s\n' "${CANDIDATES[@]}" >&2 exit 1 fi echo "==> Launching $APP_PATH" # -W waits until the (menu-bar) app terminates; --args forwards any extra flags. exec open -W "$APP_PATH" --args "$@"