OS X: Enforce Wallpaper On Mavericks and Yosemite With launchd And Python

OS X: Enforce Wallpaper On Mavericks and Yosemite With launchd And Python

If you always want a Mac to have the same wallpaper no matter what, you need a way to enforce it and there are many ways to do this:

Enforcing the wallpaper was a bit easier in older versions of OS X, but ever since Mavericks came out, the wallpaper settings are stored in a database file (as opposed to a simple .plist).

I usually opt for config profiles whenever possible, but modifying a database doesn’t work from a config profile.  I decided to use a Launch Agent paired with a script that sets the wallpaper back to my desired file if anyone decides to change it.

The Launch Agent

This runs every 30 seconds and runs my script, located in /usr/local/triggers/enforceWallpaper.py .

The Script

This checks if the wallpaper is still the picture I designate.  If it isn’t, it will run some Python code to set all screens back to the correct image.

It works well and I have been using it for quite some time.