I have seen existing questions (Assign Application Windows to Different Spaces/Desktops, Spaces in Mavericks: apps do not remember their space, How to have certain *windows* start in different spaces during start up?) related to this but I could not find a satisfactory answer:

I would like to assign a window of a specific app, say Firefox, to, for e.g., space number 2 on my Mac running Catalina.

Is there a way to achieve this programmatically, using bash or AppleScript?

For e.g., the script algorithm could be:

  1. Access the space identifier (if it exists) and store it somewhere
  2. Access the application window identifier and store it somewhere
  3. If a space is logically a collection (array) of app windows, assign the app window to the correct array related to that space.
  • Can you please add links to the questions you‘ve already looked at, and list the things you‘ve tried?
    – nohillside
    Jan 1, 2021 at 7:45
  • Is there a particular need to script this? It's a 2 second job to assign an app to a space. It's not possible to assign a single window to a space, except temporarily - which takes the same 2 seconds.
    – Tetsujin
    Jan 1, 2021 at 8:46
  • @nohillside, done. Jan 3, 2021 at 0:41
  • @Tetsujin, I would like to assign specific spaces to contexts, like a space for coding, a space for video editing, and so on. Each space should contain app windows relevant to that context. Also, I have already clarified in the question that I'm not looking to assign an app to a specific space but an app window. Jan 3, 2021 at 0:44
  • I'd have a look at what's on offer if you search "mac window manager". I'm pretty sure you have to dig in at code-level, you can't do it with Applescript. Apple forgot all about Spaces when they introduced fullscreen & it has languished unfinished ever since, I'm afraid.
    – Tetsujin
    Jan 4, 2021 at 11:36


You must log in to answer this question.

Browse other questions tagged .