How to keep apps from adding themselves to login items?

Update*

if you do a get info on the ~/Library/Preferences/com.apple.loginitems.plist file and tick the lock checkbox.

enter image description here

No changes will be written to the file. Therefor on next login there will be no additions.

I just tested this and it worked. But cannot guarantee that this may or may not be a good thing to do. I my self will use my Answer below.


You can set a launchAgent to watch for changes on the ~/Library/Preferences/com.apple.loginitems.plist file

In my example here I use a launchAgent to watch for the change and then run a command to notify me. In this case I use the command tool growlnotify

<?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>Label</key>
    <string>loginItems</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/growlnotify</string>
        <string>-n</string>
        <string>login items change</string>
        <string>-m</string>
        <string>login items change</string>
        <string>-s</string>
    </array>
    <key>WatchPaths</key>
    <array>
        <string>/Users/USERNAME/Library/Preferences/com.apple.loginitems.plist</string>
    </array>
</dict>
</plist>

I actually made this using lingon which take some of the pain out of making launchAgent.

The command I run is :/usr/local/bin/growlnotify -n "login items change" -m "login items have been changed" -s

Note this is a simple example. And you should remember that any changes may take a short while to be written to the plist. But my tests have shown it to work.