#!/bin/sh # # © 2024 F1248 # See LICENSE.txt for license information. # PATH=/usr/bin:/bin set -e is_recoveryos=$([[ ! -e /System/Library/CoreServices/Finder.app ]] && echo true || echo false) if $is_recoveryos; then if ! (( $(sw_vers -productVersion | cut -d "." -f 1) >= 14 )); then echo "\nError: Genius requires macOS Sonoma 14 or later in recoveryOS!\n" >&2 exit 1 fi echo "\nNote: Genius only remains installed until restarting." else if ! (( $(sw_vers -productVersion | cut -d "." -f 1) >= 13 )); then echo "\nError: Genius requires macOS Ventura 13 or later!\n" >&2 exit 1 fi fi echo "\nPreparing..." if [[ -w /Applications ]]; then cd /Applications else mkdir -p ~/Applications cd ~/Applications fi if [[ -e Genius.app && ( ! -f Genius.app/Contents/Info.plist || $(defaults read "$PWD/Genius.app/Contents/Info.plist" "CFBundleIdentifier") != "dev.F1248.Genius" ) ]]; then echo "\nError: A different app already exists at $PWD/Genius.app!\n" >&2 exit 1 fi echo "Quitting Genius..." if $is_recoveryos; then killall -q Genius || true else for _ in $(pgrep -x Genius); do osascript -e "quit app \"Genius\"" done fi echo "Downloading..." curl --no-progress-meter https://nightly.link/F1248/Genius/workflows/Build-app/main/Genius.zip --location --remote-name echo "Installing..." unzip -q -o Genius.zip rm -r -f Genius.app unzip -q Genius.zip if $is_recoveryos; then echo "Creating alias..." echo "\nalias genius=\"$PWD/Genius.app/Contents/MacOS/Genius &> /dev/null\"" >> ~/.bash_profile fi echo "Cleaning up..." rm Genius.zip echo "Opening..." if $is_recoveryos; then Genius.app/Contents/MacOS/Genius &> /dev/null echo "\nNote: To reopen Genius run \`genius\` in a new shell.\n" else open Genius.app sleep 0.5 open Genius.app # work around `open` opening apps in the background when not already running fi echo "Done."