#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "$ROOT/lib.sh" need_cmd brew #────────────────────────────────────────────────────────────── # STATE: Cask applications to install (edit this list) #────────────────────────────────────────────────────────────── CASKS=( orion ghostty raycast obsidian iina zed font-jetbrains-mono-nerd-font protonvpn proton-drive proton-pass libreoffice logi-options+ ) #────────────────────────────────────────────────────────────── # LOGIC: Idempotent convergence (strict mode) #────────────────────────────────────────────────────────────── log "Syncing casks (strict mode)" mapfile -t installed < <(brew list --cask 2>/dev/null || true) # Install missing for cask in "${CASKS[@]}"; do if ! brew list --cask "$cask" &>/dev/null; then log "Installing: $cask" brew install --cask "$cask" else log "Already installed: $cask" fi done # Remove extras (strict convergence) for pkg in "${installed[@]}"; do [[ -z "$pkg" ]] && continue keep=false for cask in "${CASKS[@]}"; do [[ "$cask" == "$pkg" ]] && keep=true && break done if [[ "$keep" == "false" ]]; then log "Removing: $pkg (not in state)" brew uninstall --cask "$pkg" || true fi done brew cleanup log "Casks synced"