Skip to content

Instantly share code, notes, and snippets.

@alloy
Created June 15, 2010 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alloy/439080 to your computer and use it in GitHub Desktop.
Save alloy/439080 to your computer and use it in GitHub Desktop.
+(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);
}
@mattetti
Copy link

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?

@alloy
Copy link
Author

alloy commented Jun 16, 2010

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.

@alloy
Copy link
Author

alloy commented Jun 16, 2010

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