From b5a6e4ca7a79bd71ef67664dfa75c82f0581e18e Mon Sep 17 00:00:00 2001 From: Nicola Tuveri Date: Sun, 17 Nov 2024 14:10:36 +0200 Subject: [PATCH 1/3] feat(docs): add guide for NSQuitAlwaysKeepsWindow setting Add documentation for the NSQuitAlwaysKeepsWindow setting in macOS. Includes instructions for setting, reading, and resetting the value. --- docs/misc/nsquitalwayskeepwindows.md | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/misc/nsquitalwayskeepwindows.md diff --git a/docs/misc/nsquitalwayskeepwindows.md b/docs/misc/nsquitalwayskeepwindows.md new file mode 100644 index 00000000..f037f0f1 --- /dev/null +++ b/docs/misc/nsquitalwayskeepwindows.md @@ -0,0 +1,52 @@ +--- +title: Keep windows when quitting an application | Miscellaneous +description: +head: + - - meta + - property: 'og:title' + content: macOS defaults > Miscellaneous > Keep windows when quitting an application + - - meta + - property: 'og:description' + content: When enabled, open documents and windows will be restored when you re-open an application. +--- + +# Keep windows when quitting an application + +When enabled, open documents and windows will be restored when you re-open an application. +This setting is the inverse of the option accessible through +System Preferences > Desktop & Dock > Close windows when quitting an application. +Requires logging out and in again before working. + +- **Tested on macOS**: + - Sequoia +- **Parameter type**: bool + +## Set to `true` (default value) + +Keep windows when quitting an application. +Open documents and windows will be restored when you re-open an application. + +```bash +defaults write NSGlobalDomain "NSQuitAlwaysKeepsWindow" -bool "true" +``` + +## Set to `false` + +Close windows when quitting an application. +Open documents and windows will not be restored when you re-open an application. + +```bash +defaults write NSGlobalDomain "NSQuitAlwaysKeepsWindow" -bool "false" +``` + +## Read current value + +```bash +defaults read NSGlobalDomain "NSQuitAlwaysKeepsWindow" +``` + +## Reset to default value + +```bash +defaults delete NSGlobalDomain "NSQuitAlwaysKeepsWindow" +``` From 1add4d2d6fb21cdd2a2028602594ed0b61bd56cd Mon Sep 17 00:00:00 2001 From: Nicola Tuveri Date: Mon, 18 Nov 2024 14:30:26 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Yann Bertrand <5855339+yannbertrand@users.noreply.github.com> --- docs/misc/nsquitalwayskeepwindows.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/misc/nsquitalwayskeepwindows.md b/docs/misc/nsquitalwayskeepwindows.md index f037f0f1..1df30120 100644 --- a/docs/misc/nsquitalwayskeepwindows.md +++ b/docs/misc/nsquitalwayskeepwindows.md @@ -1,6 +1,6 @@ --- title: Keep windows when quitting an application | Miscellaneous -description: +description: When enabled, open documents and windows will be restored when you re-open an application. head: - - meta - property: 'og:title' @@ -15,7 +15,8 @@ head: When enabled, open documents and windows will be restored when you re-open an application. This setting is the inverse of the option accessible through System Preferences > Desktop & Dock > Close windows when quitting an application. -Requires logging out and in again before working. + +⚠️ Restarting the Mac or closing the session is necessary to take the changes into effect. - **Tested on macOS**: - Sequoia From 6afc85c488a0cfaab6b1820ee9674a820f7fae8e Mon Sep 17 00:00:00 2001 From: Nicola Tuveri Date: Mon, 18 Nov 2024 14:59:46 +0200 Subject: [PATCH 3/3] Add a "Set value from UI" section See https://github.com/yannbertrand/macos-defaults/pull/399#pullrequestreview-2441217153 --- docs/misc/nsquitalwayskeepwindows.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/misc/nsquitalwayskeepwindows.md b/docs/misc/nsquitalwayskeepwindows.md index 1df30120..a933e11c 100644 --- a/docs/misc/nsquitalwayskeepwindows.md +++ b/docs/misc/nsquitalwayskeepwindows.md @@ -13,8 +13,6 @@ head: # Keep windows when quitting an application When enabled, open documents and windows will be restored when you re-open an application. -This setting is the inverse of the option accessible through -System Preferences > Desktop & Dock > Close windows when quitting an application. ⚠️ Restarting the Mac or closing the session is necessary to take the changes into effect. @@ -51,3 +49,11 @@ defaults read NSGlobalDomain "NSQuitAlwaysKeepsWindow" ```bash defaults delete NSGlobalDomain "NSQuitAlwaysKeepsWindow" ``` + +## Set value from UI + +This setting is the inverse of the following option accessible through +System Preferences. + +1. Open the Desktop & Dock preference pane in System Preferences. +2. Toggle "Close windows when quitting an application".