1

How to check which applications enabling SMLoginItemSetEnabled?

Terminal or which folder, file contains it?

I run 2 applications below but it can't launch at login => I need check helper app is enabling or not.

http://martiancraft.com/blog/2015/01/login-items/

https://github.com/keith/LoginItemTest

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Huynh Inc
  • 2,010
  • 1
  • 25
  • 42

2 Answers2

1

You can check the login item status using SMJobCopyDictionary(or even SMCopyAllJobDictionaries) like this:

- (BOOL)launchAtLoginWithBundleId:(NSString*)bundleId {
    CFDictionaryRef dict = SMJobCopyDictionary(kSMDomainUserLaunchd, (CFStringRef)bundleId);
    if (dict == NULL) {
        return NO;
    }
    CFRelease(dict);
    return YES;
}
Valentin Shergin
  • 7,166
  • 2
  • 50
  • 53
0

Apple didn't recommend use

SMJobCopyDictionary

@discussion The contents of the returned dictionary are NOT wholy representative of the property list on-disk and are not stable from release to release. This routine is deprecated and will be removed in a future release. There will be no provided replacement.

Better use SMCopyAllJobDictionaries method

BOOL enabled = NO;
NSArray *jobs = (NSArray*)SMCopyAllJobDictionaries(kSMDomainUserLaunchd);

if (jobs || [jobs count]>0) {
    for (NSDictionary *job in jobs) {
        if ([[job objectForKey:@"Label"] isEqualToString:bundleId]) {
            ret = [[job objectForKey:@"OnDemand"] boolValue];
            break;
        }
    }
}

[jobs release];
Community
  • 1
  • 1