MacOS – Remember desktop state after reboot

applescriptcommand lineexposemacmacos

Does anyone know if desktop switching can be done programatically? Exposé activation and deactivation? I know of the screencapture command for the last part of my proposed solution.


I would like to be able to restore my desktop work environment after a reboot. I have one idea how to do this.

Reason: I reboot every 2 – 4 weeks. I have 9 virtual desktops, each with a few to a dozen windows and applications. After a computer reboot it feels like a brain reboot and takes a few days to get everything back.

Concept: Manually prior to a planned reboot, or perhaps once a day via cron in case of accidental reboot or system freeze, I'd like to somehow capture the system state in order make recovery post-reboot easier.

Ideal Solution: I prefer the CLI. My ideal solution would be a text file of open files on each desktop, and terminal windows on each desktop, and what folder those terminal windows are in. I could then write a script that would go to desktop 1, open all the PDFs there in Preview, open all the .m files in AquaMacs, and open the terminals and cd them to the correct folder, etc. Repeat for each desktop.

I think AppleScript could easily tell me what PDFs are open in Preview.app, but I don't think it can tell me what desktop they are on. Same with Terminal.app

Proposed Solution: Screenshots of each Desktop while in Exposé mode.

Is there a way to script switching from Desktop #1 through Desktop #9, where at each Desktop, it activates Exposé and takes a screenshot?

Now, after a reboot, I can at least go to a folder, open the 9 screenshots, and manually see what application and what files were open where.

Best Answer

do you ever try Relaunch application:

Relaunch saves you time by taking Snapshots of which applications you are using, and starts them back up for you. Think of it as a launcher on steroids that lets you switch between work contexts with one click.

you can take a snapshot before restart your system and after that double click on the snapshot you created then it restored all your files and application you worked on.