Re: [HELP] How to change Desktop background pic in OSX from Cocoa-Java?
Re: [HELP] How to change Desktop background pic in OSX from Cocoa-Java?
- Subject: Re: [HELP] How to change Desktop background pic in OSX from Cocoa-Java?
- From: Jonathan Hendry <email@hidden>
- Date: Sun, 1 Jul 2001 23:21:27 -0500
On Sunday, July 1, 2001, at 06:31 , David Remahl wrote:
Uhm, actually it is a Finder thing...Finder is responsible for the
desktop and it does what it sees fits with the background...Finder
stores its preferences for the desktop in this structure in its
.plist preferences file:
DesktopViewOptions = {
ArrangeBy = grid;
BackgroundFlags = 0;
BackgroundPictureURL =
"file://localhost/Users/chmod007/Pictures/Familjebilder/Digitalkamera Tacha/
MVC-020S.JPG";
BackgroundType = PctB;
IconSize = 32;
};
But I dont think that that is anything you should go in and modify
since the format may change in the future...
You can change it through NSUserDefaults. In Objective C the
code looks something like this:
NSUserDefaults* defs = [[NSUserDefaults alloc]
initWithUser:NSUserName()];
NSMutableDictionary* finderDefs = NULL;
[defs addSuiteNamed:@"com.apple.finder"];
viewDict = [defs dictionaryForKey:@"DesktopViewOptions"];
finderDefs = [[defs
persistentDomainForName:@"com.apple.finder"] mutableCopy];
if (NULL != viewDict)
{
NSMutableDictionary* mCopy = [viewDict mutableCopy];
NSURL* url = [NSURL fileURLWithPath:newPicture];
[mCopy setObject:[url description]
forKey:@"BackgroundPictureURL"];
[finderDefs setObject:mCopy forKey:@"DesktopViewOptions"];
[defs setPersistentDomain:finderDefs
forName:@"com.apple.finder"];
[defs synchronize];
}
A change would also require a restart of finder...
Yep. You can change the default, then use the Force Quit
panel to relaunch Finder. You'll see the new image when it
restarts.
I doubt it, but maybe finder supports changing the background
using applescript...
Nope. Not yet, anyway.
- Jon