87aaf25235
lib/brew.sh: Define _SSR_DEPRECATED_TAPS list (homebrew/core, /cask, /services, /test-bot, /bundle, /cask-fonts, /cask-drivers, /cask-versions). _ssr_brew_strip_deprecated_taps removes matching 'tap "…"' lines after dump so they never cause "Tapping X has failed!" errors on restore. lib/macos-prefs.sh: Add com.apple.controlcenter, com.apple.systemuiserver and com.apple.notificationcenterui to SSR_MACOS_PREF_DOMAINS_DEFAULT so Control Centre module toggles, menu-bar extras order and Notification Centre widgets are included in the pref snapshot on every sync. Also add ControlCenter to the post-import service restart list. lib/macos.sh: Add ControlCenter to ssr::macos::restart_ui so the menu bar and Control Centre panel pick up restored prefs immediately after mackup. Kill cfprefsd first in all restart sequences to flush the pref cache. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.2 KiB
Bash
61 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# lib/macos.sh — macOS system preferences.
|
|
# Sourced by `ssr restore`. Each setting is idempotent.
|
|
|
|
ssr::macos::apply_defaults() {
|
|
local script="${1:-${SSR_MACOS_DEFAULTS:-$SSR_ROOT/config/macos-defaults.sh}}"
|
|
if [[ ! -f "$script" ]]; then
|
|
ssr::warn "macOS defaults script missing: $script (skipping)"
|
|
return 0
|
|
fi
|
|
ssr::log "Applying macOS defaults from $script"
|
|
# shellcheck disable=SC1090
|
|
bash "$script"
|
|
ssr::ok "macOS defaults applied"
|
|
}
|
|
|
|
ssr::macos::install_rosetta() {
|
|
if /usr/bin/arch -x86_64 /usr/bin/true >/dev/null 2>&1; then
|
|
return 0
|
|
fi
|
|
if [[ "$(uname -m)" != "arm64" ]]; then
|
|
return 0
|
|
fi
|
|
ssr::log "Installing Rosetta 2"
|
|
sudo softwareupdate --install-rosetta --agree-to-license
|
|
}
|
|
|
|
# Allows non-App-Store apps to run. Requires sudo. Skipped unless explicitly
|
|
# enabled, because disabling Gatekeeper has security implications.
|
|
ssr::macos::disable_gatekeeper() {
|
|
[[ "${SSR_DISABLE_GATEKEEPER:-false}" == "true" ]] || return 0
|
|
ssr::warn "Disabling Gatekeeper (SSR_DISABLE_GATEKEEPER=true)"
|
|
sudo spctl --global-disable
|
|
}
|
|
|
|
# Restart macOS UI services that read preference files restored by Mackup.
|
|
# Called after mackup restore so Dock/Finder/menubar pick up the new plists.
|
|
ssr::macos::restart_ui() {
|
|
ssr::log "Restarting UI services (Dock, Finder, SystemUIServer, ControlCenter, cfprefsd)"
|
|
local svc
|
|
# cfprefsd first: flushes pref cache so subsequent restarts read fresh plists.
|
|
for svc in cfprefsd Dock Finder SystemUIServer ControlCenter; do
|
|
killall "$svc" 2>/dev/null || true
|
|
done
|
|
# Brief pause so cfprefsd flushes its cache before processes re-read prefs.
|
|
sleep 2
|
|
ssr::ok "UI services restarted — Dock, Finder, Control Centre and menu bar will refresh."
|
|
}
|
|
|
|
ssr::macos::open_installed_casks() {
|
|
[[ "${SSR_OPEN_CASKS:-false}" == "true" ]] || return 0
|
|
local cask_dir
|
|
cask_dir="$(brew --caskroom 2>/dev/null)" || return 0
|
|
[[ -d "$cask_dir" ]] || return 0
|
|
ssr::log "Opening installed cask apps for first-run config"
|
|
find "$cask_dir" -maxdepth 3 -iname '*.app' -print0 \
|
|
| while IFS= read -r -d '' app; do
|
|
open "$app" || true
|
|
done
|
|
}
|