4

I'm making a mac app using atom shell that lives in the menubar. I was wondering what my options would be for getting it to run at startup.

  • Does it have to be done manually by the user?
  • Do I need permission from the user to do this?
  • How would I do it programmatically with node / bash?
  • Is there an existing thing within atom shell to do this?
  • Is there an existing module that can do this?

4 Answers 4

6

Give the auto-launch module a try, it should do what you want. To answer your questions:

  • No
  • No, but it'd be Classier™ if you asked first
  • See Above
  • No
  • See Above.
3

Electron now offers an official API for setting the app to auto-start on Windows and Mac.

https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows

0

You can also create an app directory in side /applications/Atom.app/Content/resources directory of atom and symlink to your files. This will launch your app on startup.

0

options would be for getting it to run at startup.

Assuming you want this application to launch for each user, as they log on, you would set up the app as a LaunchAgent.

Simply create a plist file that describes what the job is to do and copy the plist to /Library/LaunchAgents.

The plist would be something like this: -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ProgramArguments</key>
    <array>
        <string>My_executable</string>
        <string>some_command_line_parameter</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>Label</key>
    <string>com.mycompany.myapp</string>
</dict>
</plist>

Replace My_executable with the full path to the application (if it's a .app, point to my_application.app/Contents/MacOS/my_binary) and add command line parameters as required. If atom_shell requires launching a shell, you would use this as the application to run and your script as a command-line parameter.

Also ensure you set the label to a unique URI.

4
  • What if the path changes? Commented Jan 27, 2015 at 18:57
  • You could point the path of the plist to a script, which reads the path from a file, or other source. Why is the path changing? Surely, that means you're executing a different application. Commented Jan 28, 2015 at 9:14
  • I have tried this solution and have not been able to make it work. The program just doesn't run. I'm not really sure it's supposed to work for .app files and GUI applications.
    – thomasb
    Commented Nov 3, 2016 at 15:36
  • 1
    @thomasb Works just as well for gui app bundles, but you'll need to specify the full path to the executable binary inside the app bundle as the first Program Argument. So it would be something like My_executable/Contents/MacOS/My_executable Commented Nov 3, 2016 at 16:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.