Keep apps from adding themselves to login items when installing them.

Some times when you install applications they also add them selves to the login items.

This means they will startup when you login to your account. Which in some cases is not desirable.

Someone asked on Stackoverflow how to stop this.

I posted two approaches.

  1. Lock the login items preference file. items preference file.
  2. Get notified when there is a change to your login

Approach 1

Do a get info  (command + i ) on the ~/Library/Preferences/ 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 tested this and it worked.

I cannot guarantee that this  is or is not be a good thing to do. But cannot think of anything that will be affected apart from when you want to add something. And the you just have to reverse the lock on the file.



I my self will  am using the approach below.

I set a launchAgent to watch for changes on the ~/Library/Preferences/ file

In my example here I use a launchAgent to watch for any change and then run a command to notify me.

In this case I use the command tool growlnotify to display a  Growl notification.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
        <string>login items change</string>
        <string>login items change</string>

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

The command I run in the launchAgent 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.

If you use the above code change ”

"YOUR-USERNAME-HERE" to your account user name.

and save the file in ~/Library/LaunchAgents as a .plist file

On that note. These approaches are aimed at per user account but in theory you should be able to do them for the global  /Library/LaunchAgent which affects all accounts.

More info.

launchd agent is like a launchd daemon, except that it runs on behalf of a particular user. It is launched by launchd, typically as part of the process of logging in the user. A third party launchd agent should be installed by adding a property list file to the ~/Library/LaunchAgents directory (to be invoked just for this user) or /Library/LaunchAgents directory (to be invoked for all users).


Hi, Please Leave a Reply