Created
June 15, 2010 12:49
-
-
Save alloy/439080 to your computer and use it in GitHub Desktop.
This file contains 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 characters
+(void)addAppToLoginItems:(NSURL *)url hide:(BOOL)hide | |
{ | |
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, | |
kLSSharedFileListSessionLoginItems, NULL); | |
LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(loginItems, | |
kLSSharedFileListItemLast, NULL, NULL, (CFURLRef)url, NULL, NULL); | |
CFRelease(item); | |
CFRelease(loginItems); | |
} |
In the previous rev you'll find some pure Ruby to add an app to the loginitems. However, after further investigation, it turned out that that way you miss the aliasData. Meaning that if you move the app, the login item is broken and automatically removed. With this API the alias data is generated and works as expected. Only problem is that there's no BS file for this framework, and generating one still won't make it work out of the box...
Does that answer the question? I'm not sure what more code you'd like to see.
Oops, I now see I'm not actually doing anything with the 'hide' param, will fix that later today.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
your tweet mentions adding an app to the login items with MacRuby http://twitter.com/alloy/status/16222135985 Can you show more of the code?