Let me get this right out. I upgraded to MacOS 15 beta and it totally borked my machine. I had to do a full, fresh reinstall.
Totally my fault, and I should have prepared better.
So now, I’m trying to remember to capture my personal settings so I can use a shell script to restore them in case of emergency with defaults
With the help of ChatGPT and a lot of stupidity, I have created this:
#!/bin/bash
# Set the DEBUG flag (default is false)
DEBUG=false
# Define a function for logging debug information
log() {
if [ "$DEBUG" = true ]; then
echo "$@"
fi
}
# Define a function for running commands with error suppression unless DEBUG is true
run_command() {
if [ "$DEBUG" = true ]; then
"$@"
else
"$@" 2>/dev/null
fi
}
# Step 1: Define directories for temporary files
before_dir="/tmp/before_defaults"
after_dir="/tmp/after_defaults"
mkdir -p "$before_dir" "$after_dir"
# Step 2: Capture system-wide and global preferences
echo "Reading user-specific global preferences..."
run_command defaults read -g > "$before_dir/user_global_defaults.plist"
echo "Reading system-wide global preferences..."
run_command sudo defaults read -g > "$before_dir/system_global_defaults.plist"
echo "Reading user-specific system preferences..."
run_command defaults read > "$before_dir/user_system_defaults.plist"
echo "Reading system-wide system preferences..."
run_command sudo defaults read > "$before_dir/system_system_defaults.plist"
# Step 3: Get all domains and capture their preferences with and without sudo
echo "Reading defaults for all domains..."
domains=$(run_command defaults domains)
for domain in $domains; do
log "Reading user-specific defaults for domain: $domain"
run_command defaults read "$domain" > "$before_dir/${domain}_user_defaults.plist"
log "Reading system-wide defaults for domain: $domain"
run_command sudo defaults read "$domain" > "$before_dir/${domain}_system_defaults.plist"
done
# Step 4: Capture network settings (excluding Launch Services to reduce noise)
echo "Capturing network settings..."
run_command sudo cp /Library/Preferences/SystemConfiguration/preferences.plist "$before_dir/network_settings.plist"
echo "Current preferences saved. Please make your changes now."
echo "Press any key to continue once you've made the changes..."
read -n 1 -s
# Step 5: Capture updated defaults
echo "Reading updated user-specific global preferences..."
run_command defaults read -g > "$after_dir/user_global_defaults.plist"
echo "Reading updated system-wide global preferences..."
run_command sudo defaults read -g > "$after_dir/system_global_defaults.plist"
echo "Reading updated user-specific system preferences..."
run_command defaults read > "$after_dir/user_system_defaults.plist"
echo "Reading updated system-wide system preferences..."
run_command sudo defaults read > "$after_dir/system_system_defaults.plist"
echo "Reading updated defaults for all domains..."
for domain in $domains; do
log "Reading updated user-specific defaults for domain: $domain"
run_command defaults read "$domain" > "$after_dir/${domain}_user_defaults.plist"
log "Reading updated system-wide defaults for domain: $domain"
run_command sudo defaults read "$domain" > "$after_dir/${domain}_system_defaults.plist"
done
echo "Capturing updated network settings..."
run_command sudo cp /Library/Preferences/SystemConfiguration/preferences.plist "$after_dir/network_settings.plist"
# Step 6: Compare before and after to identify changes with unified diffs and output results directly
echo "Comparing preferences and generating diffs..."
# Global and system diffs
echo "Comparing global and system preferences..."
diff -u "$before_dir/user_global_defaults.plist" "$after_dir/user_global_defaults.plist" | sed '/^\s*$/d'
diff -u "$before_dir/system_global_defaults.plist" "$after_dir/system_global_defaults.plist" | sed '/^\s*$/d'
diff -u "$before_dir/user_system_defaults.plist" "$after_dir/user_system_defaults.plist" | sed '/^\s*$/d'
diff -u "$before_dir/system_system_defaults.plist" "$after_dir/system_system_defaults.plist" | sed '/^\s*$/d'
echo "Comparing Domain Specific"
# Domain-specific diffs
for domain in $domains; do
# Only run diff if both user-specific files exist
if [ -f "$before_dir/${domain}_user_defaults.plist" ] && [ -f "$after_dir/${domain}_user_defaults.plist" ]; then
#echo "Comparing user-specific defaults for domain: $domain"
diff -u "$before_dir/${domain}_user_defaults.plist" "$after_dir/${domain}_user_defaults.plist" | sed '/^\s*$/d'
fi
# Only run diff if both system-wide files exist
if [ -f "$before_dir/${domain}_system_defaults.plist" ] && [ -f "$after_dir/${domain}_system_defaults.plist" ]; then
#echo "Comparing system-wide defaults for domain: $domain"
diff -u "$before_dir/${domain}_system_defaults.plist" "$after_dir/${domain}_system_defaults.plist" | sed '/^\s*$/d'
fi
done
diff -u "$before_dir/network_settings.plist" "$after_dir/network_settings.plist" | sed '/^\s*$/d'
# Step 7: Clean up temporary files (optional, currently commented out)
#log "Cleaning up temporary files..."
#run_command sudo rm -r "$before_dir" "$after_dir"
echo "Comparison complete."
Code language: Bash (bash)
This will basically do a scan of all defaults
settings it can find, wait for you to make changes, and then show you a diff
of what has changed.
For a bad example, I wanted to auto hide the dock:
$ bash default-changes.sh
Reading user-specific global preferences...
Reading system-wide global preferences...
Reading user-specific system preferences...
Reading system-wide system preferences...
Reading defaults for all domains...
Capturing network settings...
Current preferences saved. Please make your changes now.
Press any key to continue once you've made the changes...
Reading updated user-specific global preferences...
Reading updated system-wide global preferences...
Reading updated user-specific system preferences...
Reading updated system-wide system preferences...
Reading updated defaults for all domains...
Capturing updated network settings...
Comparing preferences and generating diffs...
Comparing global and system preferences...
--- /tmp/before_defaults/user_system_defaults.plist 2024-09-30 21:23:17.183140919 -0400
+++ /tmp/after_defaults/user_system_defaults.plist 2024-09-30 21:23:45.721177080 -0400
@@ -95,9 +95,9 @@
};
ContextStoreAgent = {
"_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/mediaUsageActivityDate" = "2024-08-15 01:49:34 +0000";
- "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2024-10-01 01:22:53 +0000";
+ "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2024-10-01 01:23:42 +0000";
"_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/mediaUsageActivityDate" = "2024-08-15 01:49:34 +0000";
- "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2024-10-01 01:22:53 +0000";
+ "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2024-10-01 01:23:42 +0000";
};
LighthouseBitacoraFramework = {
"lastAggregationDate_MLHost" = "2024-08-31 00:00:00 +0000";
@@ -6998,6 +6998,7 @@
);
};
"com.apple.dock" = {
+ autohide = 1;
"last-analytics-stamp" = (
"748840077.891269"
);
@@ -12104,7 +12105,7 @@
"com.apple.photolibraryd.curatedlibraryprocessing" = "2024-09-30 11:58:18 +0000";
"com.apple.photolibraryd.periodicmaintenance" = "2024-09-29 18:28:19 +0000";
"com.apple.proactive.PersonalIntelligence.PersonalIntelligenceMetrics" = "2024-09-29 14:29:35 +0000";
- "com.apple.proactive.PersonalizationPortrait.ClientLinkStatus" = "2024-09-22 01:54:07 +0000";
+ "com.apple.proactive.PersonalizationPortrait.ClientLinkStatus" = "2024-10-04 09:16:11 +0000";
"com.apple.proactive.PersonalizationPortrait.ContactHandlesCache" = "2024-09-29 23:56:51 +0000";
"com.apple.proactive.PersonalizationPortrait.ContactsImport" = "2024-09-29 23:57:21 +0000";
"com.apple.proactive.PersonalizationPortrait.CoreRoutineImport" = "2024-09-29 23:56:50 +0000";
@@ -12115,11 +12116,11 @@
"com.apple.proactive.PersonalizationPortrait.ExpiredLinkReview" = "2024-09-29 23:57:21 +0000";
"com.apple.proactive.PersonalizationPortrait.FeedbackProcessing" = "2024-09-29 23:56:50 +0000";
"com.apple.proactive.PersonalizationPortrait.FeedbackStreamReviewed" = "2024-09-29 23:56:51 +0000";
- "com.apple.proactive.PersonalizationPortrait.LinkStatusGeneration" = "2024-09-22 01:54:07 +0000";
+ "com.apple.proactive.PersonalizationPortrait.LinkStatusGeneration" = "2024-10-04 09:16:11 +0000";
"com.apple.proactive.PersonalizationPortrait.LogLocationPerplexity" = "2024-09-29 23:54:27 +0000";
- "com.apple.proactive.PersonalizationPortrait.LogNamedEntityFirstSource" = "2024-09-22 01:54:07 +0000";
+ "com.apple.proactive.PersonalizationPortrait.LogNamedEntityFirstSource" = "2024-10-04 09:16:11 +0000";
"com.apple.proactive.PersonalizationPortrait.LogNamedEntityPerplexity" = "2024-09-29 23:56:52 +0000";
- "com.apple.proactive.PersonalizationPortrait.LogTopicFirstSource" = "2024-09-22 01:54:07 +0000";
+ "com.apple.proactive.PersonalizationPortrait.LogTopicFirstSource" = "2024-10-04 09:16:11 +0000";
"com.apple.proactive.PersonalizationPortrait.LogTopicPerplexity" = "2024-09-29 23:57:22 +0000";
"com.apple.proactive.PersonalizationPortrait.MapsImport" = "2024-09-29 23:57:22 +0000";
"com.apple.proactive.PersonalizationPortrait.NamedEntityFiltering" = "2024-09-29 23:57:22 +0000";
@@ -12136,7 +12137,7 @@
"com.apple.proactive.PersonalizationPortrait.TopicImport" = "2024-09-26 17:42:30 +0000";
"com.apple.proactive.PersonalizationPortrait.TopicRepairAndExport" = "2024-09-26 17:45:06 +0000";
"com.apple.proactive.PersonalizationPortrait.UnsupportedClient" = "2024-09-29 23:57:21 +0000";
- "com.apple.proactive.PersonalizationPortrait.VacuumDatabase" = "2024-09-22 01:54:07 +0000";
+ "com.apple.proactive.PersonalizationPortrait.VacuumDatabase" = "2024-10-04 09:16:11 +0000";
"com.apple.proactive.ProactiveHarvesting.Cleanup" = "2024-09-29 14:29:35 +0000";
"com.apple.proactive.ProactiveHarvesting.Harvest.PeriodicBackground" = "2024-09-29 21:54:28 +0000";
"com.apple.proactived.contextualactions.training" = "2024-09-28 03:57:02 +0000";
--- /tmp/before_defaults/system_system_defaults.plist 2024-09-30 21:23:17.281165387 -0400
+++ /tmp/after_defaults/system_system_defaults.plist 2024-09-30 21:23:45.810771555 -0400
@@ -374,7 +374,7 @@
"501:com.apple.mlhost.telemetry.daily" = "2024-09-26 21:59:29 +0000";
"501:com.apple.mlhostd.daily" = "2024-09-28 08:35:02 +0000";
"501:com.apple.parsec.SafariBrowsingAssistant" = "2024-09-27 02:53:00 +0000";
- "501:com.apple.photoanalysisd.backgroundanalysis" = "2024-09-30 20:14:26 +0000";
+ "501:com.apple.photoanalysisd.backgroundanalysis" = "2024-10-01 00:02:14 +0000";
"501:com.apple.photoanalysisd.graphNonIntensiveTasks" = "2024-09-30 20:20:03 +0000";
"501:com.apple.photoanalysisd.internal" = "2024-09-15 01:53:51 +0000";
"501:com.apple.photoanalysisd.music" = "2024-09-30 17:05:59 +0000";
@@ -2312,7 +2312,7 @@
LastOSLaunchVersion = 24A335;
"baseDate.LocalBeaconingManager" = "2023-06-01 15:07:33 +0000";
lastAttemptDate = "2024-08-15 01:48:08 +0000";
- lastFinderAttemptDate = "2024-10-01 01:23:05 +0000";
+ lastFinderAttemptDate = "2024-10-01 01:23:36 +0000";
lastFinderPublishDates = {
batteryWiFi = (
"2024-09-21 01:07:39 +0000",
@@ -3859,7 +3859,7 @@
"com.apple.awdd.publication" = "2024-09-29 18:17:55 +0000";
"com.apple.awdd.trigger:0x7f004:86400:2" = "2024-09-28 13:31:28 +0000";
"com.apple.awdd.trigger:0x7f006:14400:2" = "2024-09-30 05:24:18 +0000";
- "com.apple.backupd-auto" = "2024-10-01 01:08:37 +0000";
+ "com.apple.backupd-auto" = "2024-10-01 01:38:37 +0000";
"com.apple.backupd-auto.dryspell" = "2024-09-28 01:22:46 +0000";
"com.apple.backupd.analytics" = "2024-09-28 05:36:06 +0000";
"com.apple.biome.prune-expired-events" = "2024-09-28 03:56:23 +0000";
Comparing Domain Specific
Comparison complete.
Code language: PHP (php)
You can see that there’s a lot of background noise, but in there is what I was looking for: com.apple.dock
and autohide = 1
.
Now I can head over to macos-defaults.com and I can search for com.apple.doc
and find the command to set the dock to auto hide.
defaults write com.apple.dock "autohide" -bool "true" && killall Dock
Thinking about it, this was probably a dumb example as it was easy to just go to macos-defaults.com and search for “autohide” to find it.
Well, any way do what you want with this stupid thing.
Leave a Reply