@@ -843,8 +843,8 @@ func RunFromSnapshot(cfg *config.Config) error {
843843 }
844844 }
845845
846- if err := stepMacOS (cfg ); err != nil {
847- ui .Error (fmt .Sprintf ("macOS configuration failed: %v" , err ))
846+ if err := stepRestoreMacOS (cfg ); err != nil {
847+ ui .Error (fmt .Sprintf ("macOS restore failed: %v" , err ))
848848 softErrs = append (softErrs , fmt .Errorf ("macos: %w" , err ))
849849 }
850850
@@ -936,6 +936,47 @@ func stepRestoreShell(cfg *config.Config) error {
936936 return nil
937937}
938938
939+ func stepRestoreMacOS (cfg * config.Config ) error {
940+ ui .Header ("Restore: macOS Preferences" )
941+ fmt .Println ()
942+
943+ if len (cfg .SnapshotMacOS ) == 0 {
944+ ui .Muted ("No macOS preferences in snapshot, skipping" )
945+ fmt .Println ()
946+ return nil
947+ }
948+
949+ prefs := make ([]macos.Preference , 0 , len (cfg .SnapshotMacOS ))
950+ for _ , p := range cfg .SnapshotMacOS {
951+ prefs = append (prefs , macos.Preference {
952+ Domain : p .Domain ,
953+ Key : p .Key ,
954+ Type : macos .InferPreferenceType (p .Value ),
955+ Value : p .Value ,
956+ Desc : p .Desc ,
957+ })
958+ }
959+
960+ if cfg .DryRun {
961+ ui .Info (fmt .Sprintf ("[DRY-RUN] Would restore %d macOS preferences from snapshot" , len (prefs )))
962+ fmt .Println ()
963+ return nil
964+ }
965+
966+ if err := macos .Configure (prefs , cfg .DryRun ); err != nil {
967+ return err
968+ }
969+
970+ if err := macos .CreateScreenshotsDir (cfg .DryRun ); err != nil {
971+ ui .Warn (fmt .Sprintf ("Failed to create Screenshots dir: %v" , err ))
972+ }
973+
974+ macos .RestartAffectedApps (cfg .DryRun )
975+ ui .Success (fmt .Sprintf ("macOS preferences restored (%d settings)" , len (prefs )))
976+ fmt .Println ()
977+ return nil
978+ }
979+
939980func runUpdate (cfg * config.Config ) error {
940981 ui .Header ("OpenBoot Update" )
941982 fmt .Println ()
0 commit comments