Re: Starting as Startup Item?
Re: Starting as Startup Item?
- Subject: Re: Starting as Startup Item?
- From: Mark Munz <email@hidden>
- Date: Sun, 5 Dec 2004 12:19:47 -0600
I don't know the reason you need to know the difference between
starting up as a login or not, but be careful, because this solution
will only "mostly" work.
Scenario: User adds application to Startup Items then launches your
Application from Finder.
You will be listed in the startup items, but you didn't start at
Startup.
Depending on the original need, this solution may be "good enough", but
as always, it is good to know of potential cases where it may fail so
that you can deal with it appropriately.
Mark Munz
On Dec 5, 2004, at 12:03 AM, Darkshadow wrote:
You can check the loginwindow.plist file, and see if your application
is listed there. This code should do it. Note that the autolaunched
applications could be moved in the future to some other plist, or even
not saved (like this) at all, but it has been in the loginwindow.plist
file since 10.1 (I'm not sure about 10.0; I never looked back then).
Keep that in mind if you decide to use this. Also, I think the keys
had different names in 10.1, so if you're looking for compatibility
with 10.1, you may want to check that out.
- (BOOL)isInAutoLaunchDictionary
{
NSString
*loginwindowPlist=[@"~/Library/Preferences/loginwindow.plist"
stringByExpandingTildeInPath];
NSDictionary *autoLaunchedApps=[NSDictionary
dictionaryWithContentsOfFile:loginwindowPlist];
NSArray *appsArray=[autoLaunchedApps
objectForKey:@"AutoLaunchedApplicationDictionary"];
NSEnumerator *anEnum=[appsArray objectEnumerator];
id anObject;
while ((anObject=[anEnum nextObject])) {
if ([[[NSBundle mainBundle]bundlePath] isEqualToString:[anObject
objectForKey:@"Path"]]) {
return YES;
}
}
return NO;
}
Darkshadow (aka Mike Nickerson)
On Dec 4, 2004, at 3:20 AM, Mihkel Tammepuuu wrote:
How can an application determine if it was launched as a Startup Item
on logging in to Mac OS or a usual way like (double)clicking it's
icon?
//
Mihkel Tammepyy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden