Forcing Mac OS to update default settings plist files

I'm trying to get information about the current Mission Control Spaces, specifically the current space number. I can access this info by using "defaults read com.apple.spaces". The problem is that this info only seems to update when a new space is created or deleted. So if you read this and then change the current space or open a new window, that file will still be set to the previous space until a new space is created or deleted, which would then update the file. I can't see any other way to get this information.

Is there any non-intrusive way to force the OS to update this plist file on demand (without relaunching the dock or Finder)? Or is there any other way to get the current space number any other way? Thanks

That is the preferences database. It is designed for persistence of app settings. One should not shove data into some other app's preferences file. Preferences files can change format at any time.

It is possible that the process responsible for this file may write current settings upon receipt of a HUP signal, but this is never guaranteed.

Generally speaking, if Apple wanted developers to have an interface to this data, they would have created an API to use. Lacking an official API, you'll have to get your fix in some back alley. Keep in mind that Apple can, and definitely will eventually, break your app at some point in the future.

Forcing Mac OS to update default settings plist files
 
 
Q