Forked from madrobby/gist:9f134c440bd6524e7e7a
Last active
November 25, 2020 19:39
Revisions
-
joshuatbrown revised this gist
May 8, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,7 @@ -(BOOL)appIsPresentInLoginItems NSString *bundleID = @"blah"; NSArray *jobDicts = (__bridge NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd ); NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { return [[evaluatedObject valueForKey:@"Label"] isEqualToString:bundleID] && [[evaluatedObject valueForKey:@"OnDemand"] boolValue]; }]; -
joshuatbrown revised this gist
May 8, 2014 . 1 changed file with 7 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,12 @@ -(BOOL)appIsPresentInLoginItems { NSString *bundleID = @"blah"; NSArray *jobDicts = (__bridge NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd ); NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { return [[evaluatedObject valueForKey:@"Label"] isEqualToString:bundleID] && [[evaluatedObject valueForKey:@"OnDemand"] boolValue]; }]; return [[jobDicts filteredArrayUsingPredicate:predicate] count] >= 1; } -
madrobby revised this gist
May 8, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ HELPER_BUNDLE_ID = 'blah' def launchesAtLogin? SMCopyAllJobDictionaries(KSMDomainUserLaunchd).any? do |job| job['Label'] == HELPER_BUNDLE_ID && job['OnDemand'] end end -
madrobby created this gist
May 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ -(BOOL)appIsPresentInLoginItems { NSString *bundleID = @"blah"; NSArray * jobDicts = nil; jobDicts = (NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd ); if ( (jobDicts != nil) && [jobDicts count] > 0 ) { BOOL bOnDemand = NO; for ( NSDictionary * job in jobDicts ) { if ( [bundleID isEqualToString:[job objectForKey:@"Label"]] ) { bOnDemand = [[job objectForKey:@"OnDemand"] boolValue]; break; } } CFRelease((CFDictionaryRef)jobDicts); jobDicts = nil; return bOnDemand; } return NO; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ HELPER_BUNDLE_ID = 'blah' def launchesAtLogin? !SMCopyAllJobDictionaries(KSMDomainUserLaunchd).detect do |job| job['Label'] == HELPER_BUNDLE_ID && job['OnDemand'] end.nil? end