5ed6279b51
Adds a round-trip mechanism for macOS system preferences that are not
covered by Homebrew or Mackup (Dock layout, Finder options, global
keyboard shortcuts, input sources, Spaces config, menu-bar clock,
NSGlobalDomain).
sync: `ssr sync` exports each configured domain with `defaults export`
and writes one plist per domain to <backup_dir>/macos-prefs/. Export is
soft-fail per domain so one bad domain doesn't abort the sync. Gated by
SSR_SNAPSHOT_MACOS_PREFS=true (default on).
restore: `ssr restore` replays the snapshot with `defaults import` after
the declarative config/macos-defaults.sh runs, so the snapshot is the
last writer and wins for accepted domains. Before importing, the restore
detects domains that both the snapshot and macos-defaults.sh touch and
prompts interactively:
Domain `com.apple.dock`:
Snapshot will OVERRIDE values set by macos-defaults.sh.
[A]ccept snapshot / [r]eject (keep declarative)? [A/r]:
Non-TTY (launchd, CI) falls back to SSR_PREFS_CONFLICT_DEFAULT (default
"accept"). SSR_ASSUME_YES=true skips all prompts. After import, Dock,
Finder, SystemUIServer and cfprefsd are restarted once.
New config keys: SSR_SNAPSHOT_MACOS_PREFS, SSR_MACOS_PREF_DOMAINS,
SSR_MACOS_PREF_DOMAINS_EXTRA, SSR_PREFS_CONFLICT_DEFAULT, SSR_ASSUME_YES.
ssr-status surfaces the snapshotted-domain count.
README documents the snapshot flow, default domain table, conflict UX,
and the five new config keys.
Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
1.8 KiB
Bash
Executable File
53 lines
1.8 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 and pref-snapshot summary from the last sync.
|
|
if backup_dir="$(ssr::cloud::backup_dir 2>/dev/null)"; then
|
|
if [[ -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
|
|
if [[ -d "$backup_dir/macos-prefs" ]]; then
|
|
n="$(find "$backup_dir/macos-prefs" -name '*.plist' 2>/dev/null | wc -l | tr -d ' ')"
|
|
echo " prefs snap: $n domain(s) (see $backup_dir/macos-prefs/)"
|
|
fi
|
|
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
|