HippopotamusMan

Q: Lion: failure to honor the un-setting of "Restore windows when quitting and re-opening apps" ?

I have noticed an annoying "feature" of Lion, and I'm hoping that someone might have found a workaround.

 

If I uncheck Preferences->General->Restore windows when quitting and re-opening apps, some of my apps still seem to ignore that setting after a restart.

 

Here's a scenario which illustrates the problem:

 

  1. Uncheck the Preferences setting mentioned above.
  2. Open up a few Finder windows.
  3. Open up a few Terminal windows.
  4. In the Terminal Preferences, disable everything related to Window Groups.
  5. Do a Logout or a Restart. Uncheck Reopen windows when logging back in.
  6. Relog in.
  7. Open one Terminal window.

 

After step 6, all of the Finder windows which were previously open before Logout or Restart will also reopen.

 

After step 7, all of the Terminal windows which were previously open before Logout or Restart will reopen, in addition to the single Terminal window which is manually opened after login.

 

The only way I can prevent this from happening to Terminal is to add the following two lines right before the final </dict> tag in /Applications/Utilities/Terminal.app/Contents/Info.plist:

<key>LSUIElement</key>
<string>1</string>

However, this has the undesirable side-effect of not showing anything about Terminal in the menu bar or the dock.

 

None of this used to happen in Snow Leopard, Leopard, or Tiger. Does anyone know how I can disable this unwanted window-opening-after-relogin behavior in Lion?

 

Thanks in advance.

.

MacBook Pro, Mac OS X (10.7), Unibody MacBook Pro

Posted on Aug 5, 2011 3:48 PM

Close

Q: Lion: failure to honor the un-setting of "Restore windows when quitting and re-opening apps" ?

  • All replies
  • Helpful answers

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 5, 2011 4:29 PM in response to HippopotamusMan
    Level 1 (5 points)
    Aug 5, 2011 4:29 PM in response to HippopotamusMan

    PS: I tried the following commands that were described in another thread, but they did not work. After issuing these commands and restarting (twice!), my Finder and Terminal windows from the previous login session still keep returning when I start both of those programs.

    defaults write com.apple.Finder ApplePersistenceIgnoreState YES

    defaults write com.apple.Terminal ApplePersistenceIgnoreState YES

     

    Given that these commands don't seem to work to solve the problem I'm describing, is there anything I can do in Lion to prevent this from happening?

     

    Oh ... and having to remember to close these apps with Command-Option-Q before restarting is not an acceptable option.

     

    Thanks.

    .

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 5, 2011 4:38 PM in response to HippopotamusMan
    Level 1 (5 points)
    Aug 5, 2011 4:38 PM in response to HippopotamusMan

    PPS: And in any case, Command-Option-Q doesn't work, either (sigh!). If I close Terminal with that sequence and then restart my Mac, the next time after relogin that I start Terminal, all the windows from the old session come back.

     

    Please tell me that this is a bug and not a deliberate "feature" on the part of Apple!

    .

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 6, 2011 4:07 AM in response to HippopotamusMan
    Level 1 (5 points)
    Aug 6, 2011 4:07 AM in response to HippopotamusMan

    Well, given that no one is telling me that this is a bug, I now fear that this indeed is a "feature" in Lion, and that I'm stuck with it.

  • by urabus,

    urabus urabus Aug 6, 2011 4:36 AM in response to HippopotamusMan
    Level 1 (10 points)
    Aug 6, 2011 4:36 AM in response to HippopotamusMan

    All the apps I've tried have this option - Terminal Menu>Quit (while holding the "Option" key) reveals "Quit and Discard Windows" Hope this helps.

     

    edit: Also, as you work or as you finish with things like finder windows, use the "red" close window button before you quit the app and its gone for good.

     

    Message was edited by: urabus

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 6, 2011 5:05 AM in response to urabus
    Level 1 (5 points)
    Aug 6, 2011 5:05 AM in response to urabus

    To urabus. Thank you for your reply. Unfortunately, this is does not work for me. Furthermore, even if it did work the way you said, it would not be a viable alternative for me.

     

    When I hold down the Option key and select the Terminal menu, I see this: Quit and Keep Windows, not Quit and Discard Windows. If I let go of the Option key, this menu entry changes to simply Quit Terminal. Therefore, I don't even have the option to quit and discard my windows.

     

    As I mentioned, however, even if I had the option you mention, it is not desirable for me. When I restart, I want the OS to properly close all my open windows in the same way that it did in Snow Leopard, Leopard, and Tiger. It is not desirable for me to have to manually close some or all of my apps in a special way before restart, simply to cause them to behave the way that un-checking Restore windows when quitting and re-opening apps is supposed to control.

     

    Here is one reason (out of several), for why I don't want this auto-reopen-windows-on-restart "feature": some of my Terminal windows run ssh sessions to remote sites. It is a Bad Thing for these ssh sessions to be auto-restored after Restart, without my having to specificially initiate these sessions.

     

    IMHO, Apple should offer an alternative to this undesirable behavior. For example, during the shutdown procedure which is part of a Restart, we are asked if we want to kill any open Terminal windows. The "Quit and Discard Windows" option could be offered at that point ... but it isn't.

     

    Furthermore, as I mentioned above, this unwanted behavior also occurs in Finder.

     

    Is there any option that I can set in my system or in the defaults for com.apple.Terminal and com.apple.Finder which would force an automatic "Quit and Discard Windows" on restart or re-login?

     

    Updated to add second paragraph which explains how hitting the Option key when selecting the Terminal menu does not work.

  • by urabus,

    urabus urabus Aug 6, 2011 5:09 AM in response to HippopotamusMan
    Level 1 (10 points)
    Aug 6, 2011 5:09 AM in response to HippopotamusMan

    Ok try this - Goto General Preferences>Make sure Restore windows... is unchecked. Close all the apps you're concerned about. Re-open them. Test the setting by holding the option key while using the quit menu. It should now say "Quit and Keep Windows". If so, keep the apps open and do a restart and see what you get. The idea is to to see if you get quit and keep windows optinon before you restart.

     

    Message was edited by: urabus

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 6, 2011 5:51 AM in response to urabus
    Level 1 (5 points)
    Aug 6, 2011 5:51 AM in response to urabus

    Yes. Restore windows when quitting and re-opening apps is indeed unchecked. When I do a Quit and Keep Windows and then restart, the windows indeed return when I start Terminal.

     

    If I select Restore windows when quitting and re-opening apps and stop and restart Terminal, then when I hit Option and select the Terminal menu, the menu entry indeed says Quit and Discard Windows.

     

    However, I discovered this: if Restore windows when quitting and re-opening apps is unchecked when starting Terminal, I can do a Quit Terminal, and then after restart, the old Terminal windows do not return when I start Terminal.

     

    Nonetheless, this doesn't solve my problem, for the reason I described in my previous message. To clarify: when I want to do a Restart, it is undesirable for me to have to manually quit out of my Terminal application before the Restart. The Restart should close Terminal automatically in the way that Restore windows when quitting and re-opening apps specifies.

     

    The only way I came up with to "fix" this undesirable problem is to write an AppleScript that automatically runs on startup, and which goes through the following sequence:

     

    1. Open a Terminal window (all pre-restart Terminal windows also appear).
    2. Close all Terminal windows like this ...

     

    tell application "Terminal"

        close every window

    end tell

     

    Then, the first time I manually open Terminal after restart, the pre-restart windows do not appear.

     

    This is an ugly hack, but sadly, it seems to be the best that I can do under Lion.

     

    Thanks for your help.

    .

  • by urabus,Solvedanswer

    urabus urabus Aug 6, 2011 5:50 AM in response to HippopotamusMan
    Level 1 (10 points)
    Aug 6, 2011 5:50 AM in response to HippopotamusMan

    Yes. Restore windows when quitting and re-opening apps is indeed unchecked. When I do a Quit and Keep Windows and then restart, the windows indeed return when I start Terminal.

     

     

     

    My point was to verify the Preferences option was intact. Not to actually "Quit and Kepp Windows".

     

    I believe this is what you need - look here:

     

    http://reviews.cnet.com/8301-13727_7-20083707-263/managing-mac-os-x-lions-applic ation-resume-feature/

  • by HippopotamusMan,

    HippopotamusMan HippopotamusMan Aug 6, 2011 8:15 AM in response to urabus
    Level 1 (5 points)
    Aug 6, 2011 8:15 AM in response to urabus

    Aha! That worked, urabus. Thank you! (thumbs-up and applause emoticons would go here, if this site offered them!)

     

    In summary, this is what I did:

     

    1. Open Terminal.
    2. Open up a Finder window to a work folder.
    3. In the Finder menu bar, hold down Option and select Go->Library.
    4. Navigate to Saved Application State and open it.
    5. Duplicate the com.apple.Terminal.savedState folder (it will create com.apple.Terminal.savedState copy).
    6. Drag com.apple.Terminal.savedState copy to the work folder.
    7. In the work folder, rename that to com.apple.Terminal.savedState.
    8. Delete all the contents of com.apple.Terminal.savedState in the work folder. In other words, that com.apple.Terminal.savedState folder should now be empty.
    9. Go to Terminal and issue a Quit Terminal.
    10. Depending on your system settings, the com.apple.Terminal.savedState folder might now have disappeared from Library/Saved Application State. If so, that is good. If not, delete com.apple.Terminal.savedState from the Library/Saved Application State folder.
    11. Drag the empty com.apple.Terminal.savedState folder from the work folder to Library/Saved Application State.
    12. Do a Control-Click on this com.apple.Terminal.savedState folder, and select Get Info.
    13. In the Info window, select the Locked checkbox, then close the Info window.

     

    Now, the Terminal application will not save its state on restart, nor at any other time.

     

    Thanks again for all your help!

    .

  • by urabus,

    urabus urabus Aug 6, 2011 8:12 AM in response to HippopotamusMan
    Level 1 (10 points)
    Aug 6, 2011 8:12 AM in response to HippopotamusMan

    I'm glad your issue is solved.

  • by Board Head2,

    Board Head2 Board Head2 Oct 24, 2011 8:51 AM in response to HippopotamusMan
    Level 1 (109 points)
    Oct 24, 2011 8:51 AM in response to HippopotamusMan

    It isn't only Terminal that is the problem. Here is my fix:

     

    In a Terminal window, type:

     

    1) cd ~/Library

    2) mv "Saved Application State" "Saved Application State.old"

    3) touch "Saved Application State"

     

    This creates a "Saved Application State" file instead of the folder that applications expect, and prevents them all from saving their state.

     

    As well as fixing the Terminal, now Safari does't re-open all its windows on launch and try to reconnect to all of the old web sites that I had open. I really hated this too.

     

    So now I am a happy camper again. Lion really doesn't look so bad any more.

     

    - Phil