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.

1 Answer 1


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.

  • First test was buggy - deleted comment. Relaunch is a basic start in the right direction. It only opens Preview.app, none of the PDFs. It doesn't know anything about virtual desktops. But it has some potential.
    – user588
    Commented Sep 3, 2010 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .