Categories
Apple Technology UNIX

Disable Mac OS Lion’s “Restore windows” setting on an individual per-application basis

The “General” PreferencePane in Lion’s ‘System Preferences’ windows contains a “Restore windows when quitting and re-opening apps” item. However, sometimes this behaviour does’t make sense – after a reboot I found, for example, that the OS X Installer had re-launched and was asking for a package to install!

This can be prevented on a per-application basis with the Terminal command:

defaults write ‹application id› NSQuitAlwaysKeepsWindows -int 0

(… with a terminating zero, not letter “o”)

This will affect the current user, or the entire system if prefixed with “sudo“. The Application ID can be found in ‘~/Library/Preferences‘ – so, for example, preventing Installer.app from automatically restarting can be achieved by executing in Terminal:

defaults write com.apple.installer NSQuitAlwaysKeepsWindows -int 0

… but this could also be used for other intentionally ephemeral applications such as TextEdit.app or, depending on your normal usage, Terminal.app.

8 replies on “Disable Mac OS Lion’s “Restore windows” setting on an individual per-application basis”

That I can help you with 😉

Launch System Preferences, choose General, and the third item from the bottom is an option named “Restore windows when quitting and re-opening apps”. Untick this, and no app will open maintain state when restarted.

I’d miss having all of my old tabs open in Safari, though…

(You can also untick “Reopen windows when logging back in” from the Shutdown or Restart dialogs if you only want to prevent state from being restored on reboot.)

The option to remove the “reopen windows when logging back in” doesn’t work. Whether it is checked on unchecked, it will restore everything on my computer. I really really liked that Snow Leopard closed out all of the open programs before it shut down and they stayed that way. It was a nice feature. Now to have to manually close everything is a pain. I hope they fix this bug. Having a option to remove the “reopen windows when logging back in” is nice but since it doesn’t work it is a bug

Ken

In the case of doing this in reverse – i.e. if you want ‘restore windows’ off for most apps and want to individually set just one or two to restore, can I assume it’s the same but ending -int 1 instead?

How about this hint: Completely disable resume with:


rm -r "~/Library/Saved Application State/*"
chmod -R a-w "~Library/Saved Application State"

… although a neat alternative to this latter command would be:


chflags uimmutable "~Library/Saved Application State"

The article linked to above also details how to permanently disable “Reopen windows when logging back in“, and some important warnings to bear in mind with any of these fixes…

Leave a Reply to StuartCancel reply

Exit mobile version