6

I have a little program that I want to make open automatically when my mac is started up.

Because this program accepts command line arguments, its not as simple as just going to System Prefs/Accounts/Login items and adding it there...

From google, I read that I can create a .profile file in my user's home folder, and that will execute whatever I put in it... So I have a .profile page in ~ like this:

-rw-r--r--@ 1 matt staff 27 27 Sep 13:36 .profile

That contains this...

/Applications/mousefix 3.5

But it doesn't execute on startup! If I enter "/Applications/mousefix 3.5" manually into the terminal, it does work.

Any ideas?

Lebyrt
  • 1,376
  • 1
  • 9
  • 18
Matt Roberts
  • 26,371
  • 31
  • 103
  • 180
  • Your .profile is supposed to run when you open a terminal, not on startup and not when you log in to the GUI. Is that working? – Mark Baker Oct 01 '08 at 16:16

7 Answers7

11

From here and into the future, look into launchd for what you want to do. All other methods have been deprecated or are now unsupported. This is probably a bit more heavy-weight than what you want, though.

It could also be a problem with your version of the bash shell not correctly executing your .profile. Try putting the command into .bashrc in your home directory, and see if that helps.

rpj
  • 2,380
  • 2
  • 17
  • 30
4

You can use Lingon to help construct a plist file for launchd.

DGentry
  • 16,111
  • 8
  • 50
  • 66
3

The most general way of launching things on startup on MacOS is using launchd. You can create a plist file to tell it to launch your program on startup, which can include arguments.

Mark Baker
  • 5,588
  • 2
  • 27
  • 25
1

You can use Applescript which can run terminal commands, then have that applescript launched at startup.

Chris James
  • 11,571
  • 11
  • 61
  • 89
1

The .profile and .bash_profile only come into play when you open a new shell (ie. opening Terminal or entering through SSH). Also, I believe if bash detects .bash_profile it won't look for .profile
If you want it start upon login, I would look at the other suggestions about launchd

0

You could always write a wrapper script that runs it with the arguments you want

Mark Baker
  • 5,588
  • 2
  • 27
  • 25
0

Thanks all. The launchd solution is pretty cool, yes its heavyweight for such a simple thing, but its good to know, and as a developer I'm happy to tinker about :)

Matt Roberts
  • 26,371
  • 31
  • 103
  • 180
  • launchd isn't really all that heavyweight - it goes to some lengths to be as efficient as possible for what it does. It's Open Source so you can check it out yourself if you like: http://launchd.macosforge.org/ – Chris Hanson Oct 03 '08 at 09:30