X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2FXScreenSaverView.m;fp=OSX%2FXScreenSaverView.m;h=beb17fd78c80dfa90175d296421283bb01d93f2c;hp=a02a5067d3bf9da8515a5b24bcc457abb3263953;hb=ffcd2e7e3da122dbba5c4188e05d3a63d0ede26e;hpb=019de959b265701cd0c3fccbb61f2b69f06bf9ee diff --git a/OSX/XScreenSaverView.m b/OSX/XScreenSaverView.m index a02a5067..beb17fd7 100644 --- a/OSX/XScreenSaverView.m +++ b/OSX/XScreenSaverView.m @@ -1930,18 +1930,60 @@ double current_device_rotation (void) static BOOL checked_p = NO; if (checked_p) return; checked_p = YES; + + // If it's off, don't bother running the updater. Otherwise, the + // updater will decide if it's time to hit the network. if (! get_boolean_resource (xdpy, SUSUEnableAutomaticChecksKey, SUSUEnableAutomaticChecksKey)) - return; // If it's off, don't bother running the updater. + return; + + NSString *updater = @"XScreenSaverUpdater.app"; - // Otherwise, the updater will decide if it's time to hit the network. - NSString *updater = @"XScreenSaverUpdater"; - if (! [[NSWorkspace sharedWorkspace] - launchApplication:updater showIcon:NO autolaunch:NO]) { - NSLog(@"Unable to launch %@", updater); + // There may be multiple copies of the updater: e.g., one in /Applications + // and one in the mounted installer DMG! It's important that we run the + // one from the disk and not the DMG, so search for the right one. + // + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *search = + @[[[bundle bundlePath] stringByDeletingLastPathComponent], + [@"~/Library/Screen Savers" stringByExpandingTildeInPath], + @"/Library/Screen Savers", + @"/System/Library/Screen Savers", + @"/Applications", + @"/Applications/Utilities"]; + NSString *app_path = nil; + for (NSString *dir in search) { + NSString *p = [dir stringByAppendingPathComponent:updater]; + if ([[NSFileManager defaultManager] fileExistsAtPath:p]) { + app_path = p; + break; + } } -# endif // USE_IPHONE + + if (! app_path) + app_path = [workspace fullPathForApplication:updater]; + + if (app_path && [app_path hasPrefix:@"/Volumes/XScreenSaver "]) + app_path = 0; // The DMG version will not do. + + if (!app_path) { + NSLog(@"Unable to find %@", updater); + return; + } + + NSError *err = nil; + if (! [workspace launchApplicationAtURL:[NSURL fileURLWithPath:app_path] + options:(NSWorkspaceLaunchWithoutAddingToRecents | + NSWorkspaceLaunchWithoutActivation | + NSWorkspaceLaunchAndHide) + configuration:nil + error:&err]) { + NSLog(@"Unable to launch %@: %@", updater, err); + } + +# endif // !USE_IPHONE }