diff --git a/docs/installation.md b/docs/installation.md index 7eb4aa10..74d033b7 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -27,6 +27,18 @@ brew update brew install hidapi gtk+3 pygobject3 ``` +### Optional: Set up macOS launcher +* Option A (recommended): Configure a LaunchAgent to automatically start Solaar and keep it running in the background. +It will also automatically restart Solaar if it crashed or closed. +``` +bash <(curl -fsSL https://raw.githubusercontent.com/pwr-Solaar/Solaar/refs/heads/master/tools/create-macos-app.sh) +``` +* Option B: Create Solaar.app launcher in /Applications. +It can be added to Login Items to start on login, but it will not automatically recover on crashes. +``` +bash <(curl -fsSL https://raw.githubusercontent.com/pwr-Solaar/Solaar/refs/heads/master/tools/create-macos-launchagent.sh) +``` + # Installating from GitHub ## Downloading diff --git a/tools/create-macos-app.sh b/tools/create-macos-app.sh new file mode 100755 index 00000000..6109768c --- /dev/null +++ b/tools/create-macos-app.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# Helper to build a minimal macOS .app wrapper for Solaar. +set -euo pipefail + +APP_ROOT=${1:-/Applications/Solaar.app} +SOLAAR_PATH=${SOLAAR_PATH:-solaar} +SOLAAR_RESOLVED_PATH=$(command -v "${SOLAAR_PATH}" 2>/dev/null || echo "") +if [ -z "${SOLAAR_RESOLVED_PATH}" ]; then + echo "Error: '${SOLAAR_PATH}' not found" >&2 + exit 1 +fi +ICON_SOURCE=${ICON_SOURCE:-share/solaar/icons/solaar.svg} + +case "${APP_ROOT}" in + ""|"/"|".") + echo "Error: Refusing to create app bundle at unsafe location: \"${APP_ROOT}\"" >&2 + exit 1 + ;; +esac + +echo "Creating Solaar app bundle at ${APP_ROOT}" +rm -rf "${APP_ROOT}" + +APP_CONTENTS="${APP_ROOT}/Contents" +MACOS_DIR="${APP_CONTENTS}/MacOS" +RESOURCES_DIR="${APP_CONTENTS}/Resources" + +mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}" + +WRAPPER="${MACOS_DIR}/solaar-wrapper" +cat > "${WRAPPER}" <