Files
System-Sync-Restore/bin/ssr-status
T
Oliver Surke d681792148 Surface unmanaged .app bundles during sync as Markdown report
`ssr sync` now scans /Applications (and ~/Applications, configurable via
SSR_APP_DIRS) for top-level .app bundles that are neither Mac App Store
installs (Contents/_MASReceipt/receipt) nor Homebrew Cask installs, and
writes <backup_dir>/unmanaged-apps.md alongside the Brewfile. This closes
a long-standing gap in the restore story: such apps need manual reinstall
on a fresh machine, and were previously invisible to the sync workflow.

Cask detection runs fully offline against the local Caskroom and unions
four complementary strategies:

  1. Caskroom walk for .app symlinks/bundles under
     $(brew --caskroom)/<cask>/<version>/.
  2. `app "Foo.app"` declarations parsed from .rb formula receipts.
  3. `name "Foo"` field from .rb receipts (handles pkg-based casks like
     Microsoft Edge, Teams, Zoom, Google Drive, etc., that never drop
     a .app under the caskroom).
  4. `"name":["Foo"]` field from modern .json receipts (multi-line aware).

For each unmanaged app the report includes version and bundle id from the
Info.plist plus a best-effort installer link, in preference order:

  1. Sparkle SUFeedURL → derive the vendor homepage from the URL host.
  2. Bundle-id prefix match against a curated vendor map (Adobe,
     Microsoft, Docker, Cursor, Anthropic, OpenAI, JetBrains,
     GitKraken, Signal, Zoom, Telegram, Slack, Synology, Jabra, ...).
  3. DuckDuckGo search fallback (`<App name> macOS download`).

Toggles in ssr.conf.example: SSR_SCAN_UNMANAGED_APPS=true (default),
SSR_APP_DIRS=/Applications:~/Applications.

ssr-status gains a one-line summary referencing the report file.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:04:30 +02:00

48 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# ssr-status — print current state: config, cloud target, last sync, schedule.
set -euo pipefail
SSR_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=../lib/common.sh
source "$SSR_ROOT/lib/common.sh"
# shellcheck source=../lib/cloud.sh
source "$SSR_ROOT/lib/cloud.sh"
ssr::load_config
cfg="${SSR_CONFIG:-$HOME/.config/ssr/ssr.conf}"
provider="${SSR_CLOUD_PROVIDER:-icloud}"
echo "ssr status"
echo " repo: $SSR_ROOT"
echo " config: $cfg $([[ -f "$cfg" ]] && echo '(present)' || echo '(missing)')"
echo " provider: $provider"
if cloud_dir="$(ssr::cloud::resolve_dir 2>/dev/null)"; then
echo " cloud dir: $cloud_dir $([[ -d "$cloud_dir" ]] && echo '(ok)' || echo '(unreachable)')"
echo " backup dir: $(ssr::cloud::backup_dir 2>/dev/null || echo 'n/a')"
fi
state_dir="${SSR_STATE_DIR:-$HOME/.local/state/ssr}"
if [[ -f "$state_dir/last-sync" ]]; then
echo " last sync: $(cat "$state_dir/last-sync")"
else
echo " last sync: never"
fi
# Surface unmanaged-app count from the last sync, if a report exists.
if backup_dir="$(ssr::cloud::backup_dir 2>/dev/null)" \
&& [[ -f "$backup_dir/unmanaged-apps.md" ]]; then
n="$(grep -cE '^\| \[' "$backup_dir/unmanaged-apps.md" 2>/dev/null || echo 0)"
echo " unmanaged: $n app(s) (see $backup_dir/unmanaged-apps.md)"
fi
label="${SSR_LAUNCHD_LABEL:-de.surke.ssr.sync}"
service_target="gui/$(id -u)/${label}"
if launchctl print "$service_target" >/dev/null 2>&1 \
|| launchctl list "$label" >/dev/null 2>&1; then
echo " schedule: active ($label)"
else
echo " schedule: inactive"
fi