Question: I've created a very simple script that parses a webpage, finds an image, and downloads it to the machine. This script also checks every 5 minutes to see if the picture has changed, and if it has, it downloads the new one. So far, I've been successful in making this a standalone py2app, and it works fine. I can run it, and it does its thing. I have a few questions:

This app would probably be best served as a background application. I can specify that in my py2app setup.py using `LSBackgroundOnly=True` as follows:

```
"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['downloader.py']
DATA_FILES = []
plist = dict(LSBackgroundOnly=True)
OPTIONS = {'argv_emulation': True, 'plist': plist}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

```

Now. What I'd *really* like to do now is add this app to the mac login items. Is there any way to do this in py2app? I wasn't able to find anything in the documentation. I did, however, find in the Apple developer documentation how to do this with a regular Obj-C app.
[Adding Login Items](https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html#//apple_ref/doc/uid/10000172i-SW5-BAJJBJEG)

However, my Objective C knowledge is limited at best, so I struggled to come up with a good solution for this. Thanks in advance for any help.

Answer: 
I'm not familiar with py2app, but if it makes an application bundle, the process is simple.

Just run this in Terminal:

```
sudo defaults write \
    /Library/Preferences/loginwindow \
    AutoLaunchedApplicationDictionary -array-add \
    '{ Path="/Applications/YourApp.app"; }'

```

Substitute the name and path where your application is installed.
[How do you make your App open at login?](https://stackoverflow.com/questions/815063/how-do-you-make-your-app-open-at-login) shows how to add an application to the startup times from Objective-C, and the same mechanism can be used from Python using PyObjC. 

Unless your application already uses PyObjC it is probably easy to use the (deprecated) Applescript way to do the same. The following script adds Safari to the login items of the current user:

```
tell application "System Events"
make new login item at end of login items with properties {path:"/Applications/Safari.app"}
end tell

```

You can call this script using the osascript command-line tool, which you could launch from your application using subprocess.Popen. Note that running this script twice will add the application to the login items twice as well, a more complicated applescript can be used to avoid that (or you could use a configuration file to remember if you already added the app to login item, that way you won't readd the application when a user has removed it from his login items).