44

When re-opening an app, all of its windows end up on the first Space, regardless of their original placement:

Original layout: one app has two windows open, each in a separate Space

+-----[ Space 1 ]-----+ +-----[ Space 2 ]-----+ | | | | | [Chrome window 1] | | [Chrome window 2] | | | | | | | | | +---------------------+ +---------------------+ 

Incorrect layout after app restart: both windows are in the first Space

+-----[ Space 1 ]-----+ +-----[ Space 2 ]-----+ | | | | | [Chrome window 1] | | | | [Chrome window 2] | | | | | | | +---------------------+ +---------------------+ 

Is there a setting or an app that would make it possible to have apps restore their windows in the Spaces they were originally located before the app was quit?

6
  • If you're going to give separate spaces to individual windows, couldn't you just use full-screen mode, which essentially does the same thing? Commented May 28, 2015 at 15:09
  • 12
    Full-screen is not what I'm looking for. My typical workflow is to have a dedicated Space for each project I'm working on. So I have many active Spaces, each of which usually has a Chrome window, an editor window, a terminal window, etc. And I don't want to spend time distributing windows across Spaces every time I reboot, restart an app, or an app crashes. So I'm really interested in just what you see in the diagram above: to have apps or the OS remember which Space each individual window was before an app was quit. Commented May 28, 2015 at 16:56
  • 20
    Not sure why people are having issue with OP's question. I get impression that people don't understand how Spaces and Mission Control works. From my perspective, I see the OP's issue frequently, and the behaviour is inconsistent across various applications, such as Safari and Finder windows. Sometimes the windows go to their various Spaces, and sometimes not. Commented May 28, 2015 at 16:59
  • @Vzzdak Good point about the behaviour being inconsistent. Forgot to mention that. Commented May 28, 2015 at 17:46
  • 5
    Although this question is from 2015, it is still completely relevant in 2019. It's not just Chrome. I see the same issue with Finder windows, for example. Commented Jul 27, 2019 at 23:44

4 Answers 4

15

edit 2: This still doesn't COMPLETELY work for me as well: some windows are restored and some are not. The new bug id in Chromium is 1012034, and it still needs your votes!

edit: It was implemented in the latest development version (Chrome 79)!

Though, by default, in compliance with Apple's UI requirements, this feature still won't restore the workspaces if you exited Chrome with Cmd-Q. Quoting sdy, the feature author:

For folks who want Chrome to always restore windows to their original spaces, you can set that by running this command in a terminal window (for Canary, use com.google.Chrome.canary):

defaults write com.google.Chrome NSWindowRestoresWorkspaceAtLaunch -bool YES 

To go back to the default behavior, run:

defaults delete com.google.Chrome NSWindowRestoresWorkspaceAtLaunch 

Original answer: There is a bug #74812 in Chromium. Vote for it!

Same question on Superuser.

4
  • Is there the counterpart setting defaults write ... for Firefox? I usually have 6, 7 (or more) Firefox windows distributed in 4 spaces. I would actually like to restore any window of any app, but Firefox the topmost. Thx! Commented May 6, 2021 at 10:54
  • For more context, it looks that Firefox 75 solved the issue, but Firefox 77 introduced a regression bug, that broke it again when 'Displays have separate spaces' is enabled in Mission Control. The ticket is bugzilla.mozilla.org/show_bug.cgi?id=1642310 Commented May 6, 2021 at 11:08
  • This answer is Chrome-specific while the questions is for apps in general (Chrome was just an example). Commented Jun 23, 2022 at 0:43
  • I can confirm this works for Chrome but not Firefox. 'ken annoying. Commented Mar 16, 2023 at 0:33
4

I don't have a complete answer, but today, I started a decent stab at this issue using applescript. The following Applescript does roughly half the job. It reports all the windows of every application open on every desktop. The next step is to record all this in a file and then implement a script to redistribute the windows after reboot:

--This applescript reports a list of application windows present on each desktop --This is only a sample script intended to eventually be used to restore all application windows to their pre-reboot desktops tell application "System Events" set windows_string to "" set numDesktops to (first paragraph of (do shell script "strings ~/Library/Preferences/com.apple.spaces.plist | grep -c ^\\\\$")) + 1 --the following tcsh command can determine the number of desktops: -- @ x = ( `strings ~/Library/Preferences/com.apple.spaces.plist | grep -c '^\$'` + 1 ); echo $x -- switch to the first desktop: repeat with aDesktop from 1 to numDesktops key code 123 using {control down} end repeat repeat with aDesktop from 1 to numDesktops set windows_string to windows_string & return & return & "Desktop " & (aDesktop as string) & return delay 1 get (the name of every application process whose class of windows contains window) repeat with P in the result set windows_string to windows_string & return & return & P & return get (every window of process (contents of P) whose value of attribute "AXMinimized" is false) repeat with W in the result set window_name to ((name of W) as string) --Stickies window names can be multi-line, so this trims from the first hard return onward set better_window_name to (my replacePattern:"[\\n].*" inString:window_name usingThis:"") if window_name is not equal to "" then try set windows_string to windows_string & better_window_name & return on error set windows_string to windows_string & "couldn't get window name" & return end try end if end repeat end repeat --switch to the next desktop key code 124 using {control down} end repeat display dialog "List of windows on this desktop: " & return & return & windows_string end tell --Call like this: set res to my replacePattern:"\\s+" inString:"1 subtratcing-these: -2 3 4" usingThis:"-" use framework "Foundation" use scripting additions on replacePattern:thePattern inString:theString usingThis:theTemplate set theRegEx to current application's NSRegularExpression's regularExpressionWithPattern:thePattern options:0 |error|:(missing value) set theResult to theRegEx's stringByReplacingMatchesInString:theString options:0 range:{location:0, |length|:length of theString} withTemplate:theTemplate return theResult as text end replacePattern:inString:usingThis: 

Here's an example of what's the the resulting dialog I get:

List of windows on this desktop: Desktop 1 iTunes MiniPlayer FluidApp Found 626 tickets Stickies useful commands System Config Notes Special characters Profile where a python scri… XEMacs Tricks Terminal Tips Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 2 iTunes MiniPlayer FluidApp Found 626 tickets Stickies DAI Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 3 iTunes MiniPlayer Finder Searching “Scripts” Searching “Scripts” Searching “Scripts” FluidApp Found 626 tickets Stickies RPST Issues to resolve with RPST… Messages Messages (3 unread) FluidApp Found 626 tickets Terminal Terminal — -csh TextEdit Untitled 35.txt Untitled 34.txt Untitled 27.txt Untitled 15.txt Slack Slack - Princeton NPLC Safari AppleScript: Essential Sub-Routines Using Applescript to Execute a Complicated Keystroke - Stack Overflow How to restore windows to their original desktops after reboot? - Ask Different Script Editor Untitled.scpt Untitled 4.scpt Untitled 3.scpt paste_file_contents.scpt Untitled 2.scpt FluidApp Found 626 tickets Automator Subtract.workflow (Quick Action) Desktop 4 iTunes MiniPlayer FluidApp Found 626 tickets Stickies GALAXY Messages Messages (3 unread) FluidApp Found 626 tickets Terminal Terminal — -bash ???c7??? 8yc`?h=??'?]b?c??k?k????Ԫ??m??d+ — -bash Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 5 iTunes MiniPlayer FluidApp Found 626 tickets Stickies TREEVIEW When you start to work on a… TreeView stats, legend, & d… DATE OF SUBMISSION: Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 6 iTunes MiniPlayer FluidApp Found 626 tickets Stickies ALIZZI Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 7 iTunes MiniPlayer FluidApp Found 626 tickets Stickies GARCIA Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets Desktop 8 iTunes MiniPlayer FluidApp Found 626 tickets Stickies EMILIA Messages Messages (3 unread) FluidApp Found 626 tickets Slack Slack - Princeton NPLC FluidApp Found 626 tickets 
1

I have solved this issue with a personal Hammerspoon module: https://github.com/tplobo/restore-spaces

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. Commented May 2, 2024 at 10:13
0

I am aware that my answer doesn't address your issue but it is a close workaround. I am using a software called Cinch and SizeUp to reposition windows. Resizing a window across space and screen is really fast and is done using keyboard shortcut.

The software comes with a trial version for you to test it. http://www.irradiatedsoftware.com/sizeup/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.