Understanding com.apple.spaces.plist Contents – macOS Spaces Guide

macosplistspaces

I'm interested in understanding the contents of com.apple.spaces.plist because I'm trying to develop a solution to the problem of restoring apps to their original Spaces after a restart.

Looking at the value of the Space Properties property inside this plist, I see some information that looks relevant to the problem I'm trying to solve:

    "Space Properties": [
      {
        "name": "",
        "windows": [
          8557,
          114,
          183,
          91
        ]
      },
      {
        "name": "40ED97C0-613E-4E9F-ADCB-B0E4A1788987",
        "windows": [
          8557,
          114,
          188,
          337,
          338
        ]
      },
      ...

I assume the IDs under each windows property are the IDs of the applications in each Space. Is that correct?

Can I somehow, by editing this plist after a reboot, restore these window IDs to the Spaces they were assigned to before a reboot, and thus get all my windows back to where they were?

Best Answer

I assume the IDs under each windows property are the IDs of the applications in each Space. Is that correct?

That appears to be correct. I confirmed this by saving copies of com.apple.spaces.plist over time and matching the changes in its contents to windows I moved back and forth across Spaces. There is a delay of a few seconds from when you move a window to when the plist is updated to reflect that change.

Can I somehow, by editing this plist after a reboot, restore these window IDs to the Spaces they were assigned to before a reboot, and thus get all my windows back to where they were?

This doesn't seem to be possible. The plist appears to be a write-only source of information. That is, the OS periodically writes out what it's holding in memory to this file. But it doesn't update what's in memory by reading from this file.

I tested this on macOS 10.15.4 by making edits to the plist. They were ignored by the OS and simply overwritten with the current state of my windows and Spaces.