Zabobon's Dynamic Workspaces v2.25

Zabobon's Dynamic Workspaces v2.25 Macros.kmmacros (459.1 KB)

During the long lockdown I had many online meetings where I arranged several Finder Windows and Apps on my monitors and had certain Webpages open. At the end of the meeting those Windows got moved and closed and I wanted a way to Restore my nicely arranged Workspace the next time I had a similar meeting.

Version: 2.25 2021-07-26
• Increased number of possible saved Workspaces from 6 to 12
• If a single Workspace Name is edited, it becomes the chosen Workspace (in previous versions it had to be selected again from the the dropdown list after editing which was a bit clunky)

Here are the Instructions (also included in the Read Me Action in the Group).

············································································································

Author: @Zabobon

Tested with Keyboard Maestro 9.2 and Big Sur 11.3.1

PURPOSE:

Save and Restore Workspaces (Positions/Sizes of Windows for Finder Folders, Applications and Webpages).

Version 2 adds the ability to Save and Restore from a Choice of Multiple Workspaces.

············································································································
Upgrade Instructions

Disable (or Delete) any previous Zabobon's Dynamic Workspaces Macro Group. The Group and Macros might come in disabled so, they will need to be enabled to work.

The update process won't remove any previous saved Workspaces (as their Window Size/Position Data is stored in Dictionaries and Global Variables).

············································································································

SET UP: Change the Trigger Shortcuts for the 3 Macros to what you would like. I have them as:

⌃⌘S to Save to a Workspace

⌃⌘R to Restore Workspaces

⌃⌘⌫ to Clear a Workspace

············································································································

HOW TO USE:

  1. Position and size up to 8 open Applications and Finder Windows in a way that works well for a task. Open any URL in Safari or Chrome that you want to save for the task.

  2. Once all are nicely positioned, click on the first Window that you want to save the Position/Size/Path/URL and run the Save To Workspace Macro. I have the shortcut as ⌃⌘S

A Dialog will pop up allowing you to choose the Workspace to Save to. By Default a Workspace called "Workspace A" is selected.

Press OK to Save to the Workspace.

Or select another Workspace from the Dropdown List.

Or press Edit Workspaces... to change the Workspace names to something more useful to you than Workspace A,B,C,D,E,F such as "Skype Meeting" "Sound Editing" "Review Notes". Up to 6 Workspace names can be Saved.

Or press Clear Slots... to free up any slots in the current Workspace.

  1. Click on the next Window that you have positioned nicely, press ⌃⌘S to Save it to the currently selected Workspace. The process is very quick.

Up to 8 Windows can be saved for each Workspace. If an existing Application or Finder Window is resaved only the latest Position/Size/Path/URL is included in the Workspace.

  1. To Restore a Workspace, run the Companion Macro Restore Workspace. I have the Shortcut as ⌃⌘R

This presents the most recently used Workspace as default, with a Dropdown List to select any other Workspace to Restore.

Press OK to Restore the Workspace shown (all windows will be Restored to their Saved Positions, Finder Folders Saved will be Reopened and URLs will be Restored for Safari and Chrome).

  1. A third Macro, Clear All frees up any selected Workspace again by emptying all its Slots. I have the Shortcut as ⌃⌘⌫

  2. If at a future date, you want to modify the Saved Position/Size/Path/URL of any particular Window in a Workspace, just makes sure it is the frontmost Window on the Desktop and run Save To Workspace ⌃⌘S. This will overwrite the old saved Position/Size/Path/URL for the frontmost Window.

NOTES:

Finder Folders

Multiple Finder Folders can be Saved in any one Workspace.
Folders will remember their Path and automatically re-open (even if that particular Folder has been closed in the meantime).

Web Pages from Safari and Google Chrome

The current URL in Safari or Chrome will be Saved and Recalled. I have found this to be useful in repeat meetings.

Applications

Application Windows don't remember any particular file. The reasoning being that each time an Application (e.g. QuickTime) is used in a Workspace it will probably be with a different document open and it would be annoying if it kept reverting back to the document that was open at the time the Workspace was Saved. Only one instance of an Application can be Saved in each Workspace.

If the Keyboard Maestro Library is synced across multiple Macs, one benefit of the fact that Keyboard Maestro does not sync Variables & Dictionaries is that the Workspaces will be unique to each Mac.

A Workspace can have Windows arranged over multiple Monitors.

If you remame an exisiting Workspace it will become a new blank Workspace and you will lose the orginal saved Workspace.

6 Likes

UPDATE: Latest version 2.191 uploaded to replace the link at the head of this thread.

In use, I have found that I do want to clear Slots from a Workspace, to make room to save a new Window, without having to completely clear the Workspace and start from scratch. So, I have added the option to Clear Slots.

1 Like

UPDATE: Latest version 2.22 uploaded to replace the link at the head of this thread.

Added a simple Progress Bar. It shows progress of Windows being Restored and any Webpages being Restored.

1 Like

UPDATE: Latest version 2.25 uploaded to replace the link at the head of this thread.

• Increased number of possible saved Workspaces from 6 to 12
• If a single Workspace Name is edited, it becomes the chosen workspace (in previous versions it had to be selected again from the the dropdown list after editing which was a bit clunky)

(The next version will allow an unlimited number of Workspaces to be saved. But I'm still testing to make sure it is stable and backwards compatible with previous versions.)

OMG! It's here! I've been looking for something like this for months. Looking forward to trying this out - thank you.

My favorite and most-used feature of XtraFinder was its ability to save and restore Finder sets (groups of tabs) and Finder workspaces (sets of Finder wiindows, each of which may or may not have multiple tabs). My world came crashing down when XtraFinder was not M1 compatible.

If you can wait a few days, I'm working on a new version of this. Some of the interface will be different and better - so, might be worth waiting a bit for that version :grinning:

Having said that, the new version will be backwards compatible with any data saved by the current version. The main change will be ability to save as many different Workspaces as you want, rather than limiting the number.

(The thing that takes the longest with uploading a Macro here, is checking and rechecking for bugs and writing the ReadMe file of Instructions..!)

2 Likes

Too late. I already tried it. Love it.

Some feedback that you've probably already considered, all delivered with the caveat that I have no idea how difficult or time consuming they might be to implement, so please forgive me if I'm casually asking you to move mountains:

  1. Currently, adding the active folder to the most recent set involves three keypresses. (Activate macro, enter, then enter again.) Consider adding another hotkey option that would add the active folder without having to interact with the save folder dialog.

  2. Currently, the macro only saves the active folder, regardless of how many other tabs are open in the active window. It would be incredible if there was an option to save all open folders, or all open tabs in the active window. (My test of the macro involved individually saving a few dozen Finder tabs, easily ~100 keypresses; doing that in one or two would be killer. I understand that the current limit on set size may be an / the obstacle.)

  3. The save folder to set dialog defaults to the most recent set, with the option to use the dropdown menu to select a different destination. Currently, changing the destination works but the set contents list doesn't update.

  4. It would be nice to have the option of restoring a set to its own new window. I would probably set that as my default behavior.

  5. Have you considered expanding the macro to the workspace-level? Meaning save/restore for all open Finder windows, keeping track of which tabs are associated with which window. Bonus points for also remembering window position on screen.

On the chance you haven't already seen it, you might want to check out this thread. One of the scripts in the linked thread reliably retrieves the path of every open Finder tab other than searches:

tell application "Finder"
   set winList to windows
   repeat with theWin in winList
      try -- Filter-out any search windows and convert to aliases.
         set contents of theWin to (target of theWin as alias)
      on error
         set contents of theWin to 0
      end try
   end repeat
end tell

# Finish filtering
set winList to aliases of winList

Regardless of whether any of my suggestions are implemented, this absolutely rocks. Thanks again.

Glad you like it!

Of course, it's set up for my use rather than for all possible uses - but I think it's pretty flexible. And the great thing about Keyboard Maestro Macros is that you can edit them yourself and get something totally bespoke to what you want.

To save a window to the currently selected Workspace should be:

  1. Click on the window to select it
  2. Press the key combination ⌃⌘S
  3. Hit Return

(The confirmation window goes on it's own after a few seconds so, you don't have to close it.)

And if you ever move a Window in a Workspace to a better position you just repeat that and its new position overwrites the old positon.

You only have to save the Window positions once. After that, restoring the Workspace is really quick.

only saves the active folder, regardless of how many other tabs are open in the active window.

In my case I never use Finder Tabs - I'm just too old and ingrained in my ways, having separate Finder Windows open as I like to drag things from Window to Window. But with a bit of tinkering I'm sure you could adapt it.

For my use, I wanted to save several Finder Folders, a few Application Window positions and any single Webpage that was open (usually a particular shared Google Sheet).

Most of the Macro is taken up with the Prompts - and trying to make the process clear. The actual saving of the Data is relatively simple. It makes use of Keyboard Maestro Dictionaries where the "key" is whatever you call the Workspace.

Anyway, the next version will have a few refinements and I'll have a good read through your list to see if I can incorporate any of your ideas! :grinning:

Just a heads up: the one time I tried restoring a workspace with all slots full the restore was fast enough that I couldn't tell what was going on with the progress bar. All I saw was a line of vertical rectangles. (I actually assumed that you were using a font I hadn't installed :stuck_out_tongue:)

I found it was useful to have a "progress bar" for the times when the restore was taking a little time (for example if Final Cut was having to be opened, which can take a long time). It lets me know stuff is happening and that the Macro is working (and keeps my hands from typing stuff while the Windows are restored). It is "simple" in the sense that it just uses native Keyboard Maestro Actions rather than a Custom HTML - and I can understand how it works so, I can maintain it!

The sub-macro "Progress Bar" gets called each time one of the Slots in a Workspace has been restored. And this sub-macro is being called Asynchronously - meaning it isn't slowing the main Macro down. As I wanted to indicate the progress with a simple text string I used 🀆 and 🀫 symbols to indicate progress - 🀆🀫🀫🀫🀫🀫🀫 🀆🀆🀆🀆🀫🀫🀫 🀆🀆🀆🀆🀆🀆🀫 which are built into the standard Mac fonts. These symbols could be easily replaced by anything you want (even emojis) by editing the series of Actions in the Progress Bar Macro.

image

For example, you could have a series of :green_circle: :green_circle: :green_circle: :green_circle: :white_circle: :white_circle: to indicate progress.

1 Like