Script Needed: Desktop Wallpaper Path

josaxo
New Contributor

I am looking to create a script that would create a user defined Folder in System Preferences > Desktop and Screensaver > Folder Path. I believe I've tracked down the location where this value is defined. I'm wondering if I could use a defaults write command....

Plist: com.apple.desktop <key>Background</key> <dict> <key>spaces</key> <dict> <key></key> <key>0</key> <dict> <key>DSKDesktopPrefPane</key> <dict> <key>UserFolderPaths</key> <array> <string>/Library/Desktop Pictures/2012.09</string> </array> </dict>
</plist>

6 REPLIES 6

mm2270
Legendary Contributor III

posted to wrong thread.

josaxo
New Contributor

?? Please explain...

mm2270
Legendary Contributor III

Er, sorry. I meant that I posted to the wrong thread. Since there is no way to delete a post here on JAMF Nation, the only thing I could do was edit my post to the text I wrote above. Sorry for the confusion.

When I get a moment, I will see what I can come up with in a defaults command or possible using PlistBuddy to get you what you're looking for.

gachowski
Valued Contributor II
#!/bin/sh
# Setting desktop
rm /Users/$~/Library/Preferences/com.apple.desktop.plist

/usr/libexec/PlistBuddy -c "add Background:default:ImageFilePath string /Library/Desktop Pictures/mydesktop.jpg" /Users/$~/Library/Preferences/com.apple.desktop.plist

An example, change the location, name and user variables you should be good to go

nessts
Valued Contributor II

~/Library might work
but /Users/~/ is not going to do anything useful.
what is $velo
might be more wise to use plistbuddy delete to remove what you want to replace.

if this is running as a launch agent, might want to use $HOME

gachowski
Valued Contributor II

$velo is the username variable I use. I edited my post very badly