Background: the Mac OS X plist format is binary by default, which is not very good for things like tracking with git. There is a command
plutil -convert which can convert back and forth from binary to XML, but it doesn't seem to be possible to force a given plist file to stay as XML.
My idea is use the launchd WatchPaths functionality to set up two scripts, one that changes the binary file in
~/Library/Preferences to an XML file in my git repo, and another that back converts the binary file if the XML version changes (I need this second direction because I intend to use this to sync the two between two computers).
The only problem is, if I just set this up naively, it will run endlessly, because as soon as the binary file changes, it will update the XML file, but then this will be a change to the XML file, which will result in it updating the binary file, and so on.
Is there a clever way I can avoid this cycle. I guess what I want to do is to check in the script that converts from binary to XML if the thing that wrote the file last was the program that the preference file is for, or the script itself, and if it's the latter, to not run. Is there some sort of attribute I can put on the file that will tell it this, that will be cleared when the normal program writes the file?