Mavericks desktop background picture settings moved from ~/Library/Preferences/com.apple.desktop.plist
While I was preparing for Mavericks’ release, I ran across little details that had changed between Mountain Lion and Mavericks. One such detail is that the desktop background picture settings have moved.
In Mountain Lion, they were stored in the following location:
/Users/username/Library/Preferences/com.apple.desktop.plist
In Mavericks, the settings have been moved to a SQLite database at the following location:
/Users/username/Library/Application Support/Dock/desktoppicture.db
Removing desktoppicture.db causes the desktop picture to reset to whatever image is stored as /System/Library/CoreServices/DefaultDesktop.jpg
Fortunately, there are still ways to manage the desktop background picture if that’s needed. For the details, see below the jump.
Change OS X’s DefaultDesktop.jpg to set the desktop picture
Going back to 10.5.x, an easy way to set the default desktop wallpaper in OS X has been to replace the /System/Library/CoreServices/DefaultDesktop.jpg file with your own .jpg file. This method still works in Mavericks and is the approach I’ve taken in my own shop for setting the default desktop background for new accounts.
In my own shop, I wanted to set the desktop picture to be different from DefaultDesktop.jpg for one particular account: our local admin account. To help our techs quickly identify which OS they’re working on, we’ve been setting the background to match the OS version’s name:
10.6 – Snow Leopard picture
After attempting to script it, the approach I decided to use was to set the desktop picture on one machine for the local admin account, then I copied the database file. From there, I built a package to drop the database file in the right place on new machine setups. This approach has worked great to set the desktop background for my local admin account.
Setting the desktop picture with AppleScript
You can use AppleScript via osascript to set the desktop background using this command:
osascript -e "tell application \"System Events\" to set picture of every desktop to \"/path/to/image.jpg\""
Greg Neagle has developed a PyObjC script to set the desktop picture.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
'''Uses Cocoa classes via PyObjC to set a random desktop picture on all screens. | |
Tested on Mountain Lion and Mavericks. | |
See: | |
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html | |
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html | |
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSScreen_Class/Reference/Reference.html | |
''' | |
import glob | |
import random | |
from AppKit import NSWorkspace, NSScreen | |
from Foundation import NSURL | |
pictures_glob = glob.glob("/Library/Desktop Pictures/*.jpg") | |
picture_path = random.choice(pictures_glob) | |
# generate a fileURL for the desktop picture | |
file_url = NSURL.fileURLWithPath_(picture_path) | |
# make image options dictionary | |
# we just make an empty one because the defaults are fine | |
options = {} | |
# get shared workspace | |
ws = NSWorkspace.sharedWorkspace() | |
# iterate over all screens | |
for screen in NSScreen.screens(): | |
# tell the workspace to set the desktop picture | |
(result, error) = ws.setDesktopImageURL_forScreen_options_error_( | |
file_url, screen, options, None) |
Will future 10.9 OS updates overwrite the DefaultDesktop.jpg ?
unknown but possible and as a rule, don’t play around in /System/Library unless you have to
Reblogged this on Sutoprise Avenue, A SutoCom Source.
Will removing desktoppicture.db help restore the Dock as well? After I tried changing my background picture (after which my computer is now stuck on a gray background no matter what I do), I lost my Dock after restarting my computer. killall Dock doesn’t work to bring it back, and I still can’t change my desktop picture.
How are you running Greg’s script from Casper? I’m not au fait with Python so I don’t know how you’d get it to run as the currently logged in user rather than as the management account.
I gave up trying to get an answer from Apple to fix this issue in Mavericks and used Automator to write an App that changes the desktop to a predetermined image and opens via Login Items in WGM preferences. It works great!!! and if you limit Sys Prefs in WGM it is nearly as good as the old .plist method. You can “custom” make the app for any screen res or image choice so easily and drop in the applications folder via ARD etc. See my post on the Apple discussions. If any one needs any more info let me know
https://discussions.apple.com/message/23912513#23912513
P.S. Profile manager will also support this log in item as a payload if you have moved from WGM. Just add the desktop app you want to your server’s Application folder and you can then choose from the PM payload window in Login Items from the Applications+ that will launch at log in. The beauty of this is that it opens with any user who logs in.Whilst not important in a home environment but in an Education Institution or Company the need to control potentially harmful or offensive images being displayed on a desktop screen is very desirable.
To change Desktop photo, right click on the photo, go to Services and then Set Desktop Picture. No need to go into the library.
Hello,
This would be an out of the topic question. How can we temporarily disabled managed preferences in mavericks. We are still in WGM and clients mavericks. We use to clear the managed preferences by deleting /Library/Managed Preferences. However this is now not working in Mavericks
Thanks in Advance
Is that Mountain Lion picture one that you found? I never had it when I got Mountain Lion… Didn’t they remove the andromeda wallpaper from Lion in Mavericks?
Ryan,
The mountain lion picture is one that I found. It was not included with 10.8.x.
Can someone help modify Greg’s pyObjC script to include a
“defaults read com.apple.desktop Background” (or perhaps a better CFpreferences way of reading this
and then use the result of that to set the background?
This could then be run as a LaunchAgent and basically bridge what ever is set in MCX and Mavericks for setting the Desktop Background.
My PyObjC skills and CFpreferences skills are next to non-existent.
Putting this in a launch agent will do it (with the image set via MCX)
x=`defaults read com.apple.desktop Background | grep ImageFilePath | sed s:\”::g | sed s:ImageFilePath::g | sed s/\ =\ //g | sed s:*\/Library:\/Library: | sed s:\;:: | sed -e ‘s/^[ \t]*//’`; osascript -e “tell application \”System Events\” to set picture of every desktop to \”$x\””
there must be a cleaner way than I have done it though
for our corporate builds, I just replaced /System/Library/CoreServices/DefaultDesktop.jpg with our own corporate wallpaper…..
FWIW, setting the desktop picture with MCX now works for me on 10.9.2 (I don’t know if it worked previously, but i just tried with the plist I use in 10.7 and 10.8, and it worked.
i’m on 10.9.2 and changing the MCX preferences don’t change the desktop? Can you tell us how you are getting it done?
I beg to differ with this article. I mean I am pretty sure it works, but I have never had trouble changing the default desktop picture.
What I do is I add our default picture to /Library/Desktop Pictures, then I make an alias of this Desktop Wallpaper and I rename the alias to DefaultDesktop.jpg then I place it on /System/Library/Core Services
I then create a default user account and configure it, and from there the default desktop is that one, I dont have to go through all those steps above.
You can deploy a package that has the desktop picture.db to the same user’s Library/Application Support/Dock/. You can have a post install script that locks the file using chflags. Student might still change the background, but it will reset after logout.
Messing around with some new laptops running 10.9.4, I find that /System/Library/CoreServices/DefaultDesktop.jpg is now a symlink that points to /Library/Desktop Pictures/Wave.jpg. Conceivably this means that rather than replacing the picture you can now re-link to a different file.
Tried running Greg’d script, but just get an error: “Permission denied”
Why not just use Mavericks profile manager it has a “lock desktop” for users and file path preference for the user desktop in “Restrictions”. This works great and means the desktop can be changed to reflect onscreen messages and info very quickly. I have moved all my 400 macs to profilemanager now and whilst not as good as WGM its getting there.
Quick question. I’m finding that after deploying a custom path and desktop image lock via PM, if you remove that profile/payload, the desktop remains locked and unchangeable as if the profile settings, though removed, are still active somewhere. Just can’t find where they are to remove them and put that setting back to default??
So, may have found the solution/prob. The com.apple.MCX.plist had in it an entry for com.apple.desktop.plist (which doesn’t exist) I removed that entry from the MCX plist and settings went back to default FYI. Not sure why it still existed, and/or where it was reading from if the plist did not even exist?
Once the profile and preferences in Sys Prefs are deleted they should no longer be managing any settings in PM. You could try holding the alt key as you log in as admin and see if the disable management options box appears as this works for both PM and WGM as a way of turning off management settings locally. This option has to have been “checked” in the settings panel for it to work”Computer administrators may refresh or disable management”
Thanks for great tip, but still have an issue. Removing the SQLlite db does reset the desktop, but i still cannot get the old “folders” location to reset, even after removing and replacing the com.apple.desktop.plist file (which is supposed to reset any preferences). Any idea on how to completely reset the desktop preferences to the default?
This info was awesome for 10.9, unfortunately it looks like everything has changed with 10.10 (el capitan), which is typical of Apple, its not broken so lets move/change it!
Since 10.9 I have moved to Profile Manager for over 400 macs I manage whilst not as good as WGM does have a set and lock desktop in the Restrictions config profile. You can choose any desktop and the filepath for the client to use and a checkbox to prevent users changing it. WGM is now officially deprecated since 10.10 and should not be used as it will still open if you previuosly have it installed and create problems on your server.
I admin 1,000 Macs with Jamf Pro. I’m trying to install a folder of desktop picture choices and have them randomly change daily underwear High Sierra. Editing com.apple.desktop.plist (with default writes or editing the .xml) makes no difference and now it can be removed as it appears not to be used any more and doesn’t get re-created with defaults. Configuring, packaging and deploying /Users/username/Library/Application Support/Dock/desktoppicture.db doesn’t change the available options and seems to be ignore. Anyone know where this preference really gets stored?