Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register as Login Item with Cocoa?

Tags:

Google gave me: http://developer.apple.com/samplecode/LoginItemsAE/index.html

And I figured there must be a better way than using AppleScript Events.

So I downloaded the Growl sources. They use the exact sources from that Apple developer article.

Is there a better way?

(I refer to Login Items in Accounts in System Preferences, ie. making my program start when the user Logs in, programmatically)

like image 576
mxcl Avatar asked Mar 04 '09 01:03

mxcl


2 Answers

There's an API that's new in Leopard called LSSharedFileList. One of the things it lets you do is view and edit the Login Items list (called Session Login Items in that API).

BTW, I'm the lead developer of Growl. We haven't switched away from AE yet because we still require Tiger, but I'm thinking of dropping that for 1.2 (haven't talked it over with the other developers yet). When we do drop Tiger, we'll drop LoginItemsAE as well, and switch to the Shared File List API.


EDIT from the year 2012: Since 2009, when I originally wrote this answer, Growl has switched to LSSharedFileList and I've left the project.

like image 75
Peter Hosey Avatar answered Oct 04 '22 15:10

Peter Hosey


I stumbled across Ben Clark-Robinson's LaunchAtLoginController. A very elegant solution to a very common problem.

like image 41
Reed Olsen Avatar answered Oct 04 '22 15:10

Reed Olsen