Saving, Restoring, & Launching Window Layouts

I want a BTT setup where I can trigger a keyboard shortcut (⌥1, ⌥2, ⌥3, etc...) and fill my two monitors with certain programs like: Safari & Quip split half/half on main monitor with Slack & Calendar split half/half on secondary monitor. If the programs are not open, I want them to launch and be assigned their layout. I want to then be able to launch/activate other layouts like replacing Slack/Calendar with fullscreen Mail on secondary monitor. I could then use the first shortcut to go back to my original layout. I don't want any other windows that might be open to affect the layout. This would be immensely helpful to me because I often need certain layouts of programs open and I want to utilize my screen space accordingly, without having to tab into each program and window snap it to where I need each time I change layouts.

I tried to set up this, with what I thought would work, but I have lots of issues with it:

In my shortcut actions I do this:

  1. Hide All Windows (ensure no programs not in the layout will be shown)
  2. Delay? I added this in recently but I can't tell if it helps or not
  3. Launch all layout apps and show them (if already open).
  4. Restore the window layout that was previously saved (Main: Quip / Safari 50/50 split. Secondary: Slack / Mail 50/50 split)
  5. Hide programs which I want available but not visible in the layout immediately (fullscreen Spotify, Calendar, and Sketch)

When I trigger this shortcut, it doesn't really work. One of these will happen:

  1. Everything is hidden, nothing opens or is shown or applied to the layout
  2. A few windows are snapped to the layout and shown, while others are unaffected or still hidden
  3. After hitting the shortcut 5+ times, the layout might actually work with either one or zero windows out of place.

What's a better way to handle this workflow? I'm very tempted to scurry off to Display Maid (Display Maid - save and restore window layouts) but I've been a longtime BTT user and I want to know how to make it work in this app.

Thank you!

I think you won't be able to make this work reliably. The timings necessary for waiting on apps to launch, have their windows ready for resizing etc. can not be modeled using actions in BTT. A specialized app would probably be much better at this as it can contain tons of logic to somehow make this reliable.

1 Like

I see. Regardless of launching, even if the apps are open the layout does not apply correctly. I would compromise having to launch the apps but I still seem to have trouble with them applying layouts. Is there anything else here that I need to wait for before resizing? Also, will the windows still resize even though their menubar 'title' names might be different (i.e. Safari having different tabs open)

You mean the "restore window layout" action, without any of the other actions doesn't work for you?

BTT uses various heuristics to match the windows, so it can work with different titles than recorded but depends on the situation. E.g. if you recorded two Safari windows and now have two safari windows with different tabs open, BTT will randomly choose one of them.

Hi Andreas--just wanted to share a related but different Q for you. This assumes I only have one of each window open: Non-Technical User Seeking Help Re: Auto Resize 😫

Can you reply if you find a moment?

Hi Andreas, related question, where would one find a saved window layout after running the shortcut action to save a layout and give it a name?

For others who come across this thread and are interested in powerful responsive window resizing tools – you have a couple options:

  1. BTT using restore window layouts, works in most cases.
  2. macOS Automation tool Bunch (bunchapp.co) + window rearranger Moom (manytricks.com/moom). Bunch hides and opens the windows you want, Moom arranges and saves the layouts using Window Snapshots. There's even documentation explaining how to link the two.
  3. Stay from Cordless Dog for saving/recalling window layouts.
  4. Hammerspoon for general scripting (Lua), you can make it do whatever you want with your windows to the point, the Hammerspoon APIs are great. Probably the most powerful and extensible on this list, but very technical.

I hope this helps anyone with interests in saving and recalling window layouts in the future!

1 Like

@Andreas_Hegenberg Is there a way to include a regex or substring match in the window layout data? I keep two Chrome browsers open with different tabs. One is my personal Chrome profile, one is my work Chrome profile. One title always ends with Mike (Mike (personal)) and the other always ends with Mike (Mike (Work)).

This causes the windows to be unreliably restored because the saved layout data doesn't match due to the tabs always being different. If we could add a substring match or regex in the layout data, then I'd be able to make this reliable.

Mhh, I'm not sure whether this will work, but I have added regex support for the window title with 4.410 alpha (uploading now). However you'd need to manually edit the saved layout data.

I'm using all 4 apps now

  1. Hammerspoon - To do the primary window movements (including swap window positions).
  2. Moom - To save a window layout and launch them in same position every time with the help of Bunch.
  3. Bunch - To launch the apps.
  4. BTT - To move application windows "between spaces" with the Keyboard.

I need help with

  1. I need help eliminating 3 of the 4 applications if possible.

There has got to be a way to eliminate the usage of at least one or two of these tools.

For 1.) You can do almost all window movements using the "Custom move / resize" action in BTT. However swapping window positions would probably need some scripting. How are you swapping them?

For 2.) have you tried the "Save / Restore Specific Window Layout" action in BTT? Maybe in combination with the "Specific App Did Launch" trigger?

For 3.) have you tried the "Launch Application" action in BTT?

Via a Hammerspoon script that I built with the help of ChatGPT. I don't find it useful, but it's cool.