Zabobon's Dynamic Workspaces v3.10

Zabobon's Dynamic Workspaces v3.10 Macros.kmmacros (723.1 KB)

PURPOSE

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

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

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.

Here are the Instructions (fuller instructions in the ReadMe included in the Group).

············································································································
Author: @Zabobon
Tested with Keyboard Maestro 9.2 and Big Sur 11.3.1
Latest Version: 3.10 (version notes in ReadMe in Group)

Upgrade Instructions

Disable (or Delete) any previous Zabobon's Dynamic Workspaces Macro Group. Probably a good idea to just Disable the old Group at first in case you prefer it to the new version.

NOTE: This version is backwards compatible with any Workspaces created from version 2.83 onwards. From version 2.83 multiple Websites and any number or Workspaces can be saved. The Window data is saved in a different form to before 2.83 and means you would need to manually recreate any Workspaces if you are upgrading from earlier than 2.83. I have arrived at the "final" form of data saving now as it allows for unlimited Workspaces and multiple Webpages per Workspace. Any future upgrades will be tweaks and bug fixes and will stick to this data saving method.

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

Set Up

The Macro Group will come in disabled so, you will need to enable it to work.

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

⌃⌘S Save to a Workspace
⌃⌘R Restore Workspace
⌃⌘O Options

············································································································
(Detailed Instructions and Notes are in the ReadMe file.)

Save To Workspace Macro

Position and size up to 8 open Applications and Finder Windows in a way that works well for a task. Additionaly, open any URL in Safari or Chrome Website Windows and position them too (note that this Macro saves individual Window Postions - it ignore Tabs).

Once all are nicely positioned, click on the first Window that you want to save the Position/Size/Path/URL and press ⌃⌘S followed by Return to Save the Window Position/Size to the Selected Workspace. Repeat for each window you want to Save. (Click Help for detailed instructions.)

Restore Workspace Macro

To Restore a Workspace, press ⌃⌘R followed by Return to restore the Selected Workspace. (Click Help for detailed instructions.)

Options Macro

Open Options directly by pressing ⌃⌘O
Or, from either Save to a Workspace or Restore Workspaces click Options

From here you can make new Workspaces with more useful names, like "Start of Week Meeting" "Edit Review" "Zoom Studio Meeting" - that sort of thing. You can also delete Workspaces, change their names, order the list of Workspace alphabetically etc.

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

RELEASE NOTES:

Version: 3.10

• Minor Interface change.

8 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 its 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:

1 Like

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.

2 Likes

Hi!

thank you for this amazing macro. Personally, this is one of my favorite macros so far. The only issue which I'm experiencing is hang-ups when I add Safari or Chrome to the mix. For example, I have 6 apps in 1 workspace. Everything works well until KB tried to open Safari or Chrome window. It just hangs and I can see a moving KB icon in the menu bar and I have to cancel the macro manually. Hitting Control-Command-R second time ( or more ) make just thing worse ( rainbow wheel ).

I'm using KB Version 9.2 and macOS 11.5.1 on two machines. Both of them, same issue. Sometimes Safari windows appear but it's blank without a URL and it ignores the saved position on the screen.

From your description, I assume you can open and store multiple Safari / Chrome windows ( same as Finder ). Here again, Finder works, Safari doesn't.

Thank you for any suggestions.

Hi @roskozmos
I’m travelling at the moment but will endeavour to answer your questions properly once I’m back home (in a couple of days).

With this one - no, it only stores one Safari and one Chrome per Workspace. I’ll look into whether that is easy to change. I’m sure it’s possible.

Also, I’ve done a major overhaul of the whole Macro and will be uploading it soon. It will be able to store an unlimited number of Workspaces rather than limited to the 12 of the current version. I’ve also tried to streamline the Interface.

Thanks for the clarification with Safari / Chrome windows. Also, I notice, when you save the same app to multiple workspaces and combine your macro with Mission Control, these apps keep opening on previously used Spaces (Desktops). But I'm willing to ditch Mission Control in favor of having this satisfying feeling of pixel-perfect windows on the screen each time with just the press of a button.

speaking about buttons... Is it possible to assign shortcuts to each workspace? Your macro is too complex and it's easy to get lost (at least for me). I have a small MIDI controller on my desk. Would be awesome to trigger workspaces with these MPC pads.

thanks again for your work and happy traveling!

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

• Changed to allow an unlimited number of Workspaces.
• Changed to allow saving of multiple Safari or Chrome Webpages in each Workspace.
• Added Macro, "Workspaces Options..."
• Tried to simplify the interface, whilst adding more options.
• Reworked the Progress Bar to stop it vanishing and reappearing in a long Restore.

That's done for this version. But it might mean you have to manually recreate your existing Workspaces.

I couldn't recreate this. However the new version saves and restores Safari and Chrome Windows in a different way so hopefully works for you. Just one thought - it could have been the Macro taking a long time to reach a certain web address - in the new version the Progress Bar waits for each Window to be restored before moving on so, that might give a better indication of what is happening.

That was a bit of a limitation with the way Dropdown Lists work in Keyboard Maestro. I've changed the way this works in this version so that the lists always update.

I implemented this but decided it added an extra layer of complication. If you want to do this it can be done by making dedicated new Macros, each with their own shortcut keys, that set the Workspace to the one you want and then Restore their Windows. But I found that in use I never remembered which Workspace had which shortcut so it was actually quicker to just run the Restore Workspace Macro and choose the Workspace to Restore from the list.

Hello @Zabobon ,

thanks for the update! I like the new interface changes and the ability to create even more Workspaces. Progress Bar seems to work more reliably. Unfortunately, my previous issue with Safari / Chrome windows persists.

I was messing with the interface, deleted Workspace E by mistake then was unable to change the order alphabetically ( Workspace E was last in the list ). Long story short: I deleted something else and now the interface looks a bit broken.

I tried to delete the macro group, then import it again with no success. The Macro is still broken. That makes me wondering. Maybe my problem with your macro is still there, sitting somewhere in the Application Support folder I guess, so I'm still experiencing the same issues no matter which version I'm using.

I found here on the forum that all macros are stored in "Keyboard Maestro Macros.plist" I don't want to mess with that at least I have to. Do you know what else I can try to completely delete your macro?

I did try "Revert Macros" in the "File" menu, but the problem persists.

Thank you for any suggestions.

Hi @roskozmos

As long as you only deleted things using the interface (i.e. without opening up Keyboard Maestro and deleting parts of the Macros) all you would have done is delete the data that was being stored. Even if you deleted parts of the actual Macros in Keyboard Maestro you would only have broken the Macro itself and nothing else in Keyboard Maestro.

But it is a good chance to explain how the Macro stores the data and hopefully reassure you that all can easily be fixed :blush:

As you probably know Keyboard Maestro can store bits of text data in what it calls "Variables". So, if I want to store something (like the coordinates of a Window, which is four numbers - left, top, width, height) that can be done by storing those four numbers in four "Variables". And then, when I want to retrieve that data (to restore the Window position) I can call on those Variables. I think of these Variables like little user-generated files (a bit like the way Photoshop saves and retrieves user-generated image files).

For this Group of Macros I needed to store data for each Workspace and each of its 8 Windows and Safari/Chrome Webpages etc etc and for this task I used Keyboard Maestro's "Dictionaries" which are a kind of fancy variable. Again, these Dictionaries are designed to be user-generated and edited (from within Keyboard Maestro Macros).

It is worth pointing out that none of these files or any other Keyboard Maestro should ever be edited outside of Keyboard Maestro or a Macro. Do not ever go hunting around in the Finder.

From what you have said, I think the worst you can have done is either mess up my Macro (by deleting parts of it from within Keyboard Maestro - which doesn't sound like what you've done) or mess up your saved Workspaces data (by deleting from within the Macro's interface).

That will definitely fix things if you have deleted parts of the Macro itself.

But the "data" is not stored in the Macros. It is stored as lots of numbers, in the Variables and Dictionaries and they persist.

(Again, a bit like the way uninstalling and reinstalling Photoshop would not change any of the image files it had generated).

It sounds like all you have done is delete some of your Workspaces or the saved window positions in those Workspaces.

What I would do is open up my Options Macro and choose Clear Slots. Then choose the Workspace that you think you broke and Clear All its slots. Then position the windows again and resave them using the Save To Macro.

As I mention in the Notes, even deleting a Workspace name doesn't actually delete its data. It just hides the name from the list of Workspaces. So, if you wanted to change the order of the Workspaces in the list (you said you wanted them to be alphabetical) it is perfectly okay to delete all the Workspaces one by one (using the ⌫ Space option) and then type them in again one by one (using the + Workspace option). Needless to say, doing all this from the Macro interface - not by going into Keyboard Maestro itself.

And in case you are worried that these "Dictionaries" and "Variables" persist - they are the tiniest amount of data - just lists of numbers in text format. But as it is not good practice to have data hanging around that is not needed, these Macros automatically clear any data that is not needed by using "Local" and "Instance" Variables wherever possible (these only persist while the Macros are running and clear themselves out at the end of each run).

Having said all that - I will test this myself over the next days (by trying to mess things up deliberately) just to make sure it works solidly. If I find a problem, I'll upload a new version.

I actually deleted "unnamed workspace" which is last on the list.

Mac mini 2021-08-25 o 10.40.53

and after that interface looks like this

MacBook Pro 2021-08-25 o 11.22.28

Now, it seems I fixed it by recreating all Workspaces from A to L and I can see this "unnamed workspace" again on the last position. I just have to recreate my window positions again, which is ok for me.

On my second machine at work, I tried again Safari/Chrome. When macro launches one of these apps, it just stops working. When Safari/Chrome IS NOT running, then the first Safari/Chrome window will open - ignoring the saved website. If I have multiple Safari/Chrome windows in the same Workspace, just the first one works. The progress bar is still on the screen but after few minutes of waiting, I just Cancel All Macros from the menu bar.

When Safari/Chrome IS running ( without open windows ) then not even the first window will open. Macro successfully opens other apps but hangs on the slot with Safari/Chrome.

Don't know if this description can help you understand what's going on but at least I fixed the problem with the interface while writing this reply :smile:

Ah, that's very interesting and thanks for taking the time to work it out! That extra blank Workspace is a result of the list of saved Workspaces having an extra "|" at the end. The list builds up as you add more Workspaces, each separated by a "|" like:

Workspace A|Workspace B|Another Workspace|

As you add more Workspaces I had them added to the list with their name and a "|". So, adding a New Workspace would make the list:

Workspace A|Workspace B|Another Workspace|Yet Another Workspace|

To stop that extra blank Workspace being created I need make sure the list doesn't end with a "|" but should be:

Workspace A|Workspace B|Another Workspace|Yet Another Workspace

I knew that as part of my system for adding Workspaces there would always be an extra blank one at the end of the list but never realised it could cause a problem. I think it's easy to fix so I will fix that.

By the way, the generic Workspaces A, B, C etc were only meant to be a starting point. I would suggest giving your Workspaces more useful names like "Zoom Meeting" "Editing Review" based on the work they are associated with and get rid of the generic A,B,C ones.

I'm still not able to recreate this on any of my Macs (I have tried it on 4) so, I'm really not sure what is going on or why your system is different to mine. As a test I tried just adding a load of Safari and Chrome Windows and they all open really quick.

image

That is of almost zero help to you. But it shows that it can work as expected. Just a hunch, but Mac OS Big Sur can deny Keyboard Maestro certain permissions to do things (like controlling specific Apps). When Keyboard Maestro first tries to do something in Safari or Mail a dialog can pop up asking for you to allow it control it. The problem with solving this kind of stuff is that it could be one of many things and it's hard to find the cause. All I can say is that what this Macro does is very simple and generic so, should just work...
Can you let me know what versions of Keyboard Maestro, Mac OS, Safari and Chrome you have?

Yeah, I've seen that before and allowed this king of pop-up windows. I've also turned on the "Full Access" setting in "Security & Privacy", also as "Accessibility" and "Screen Recording" in System Pref. for KM.

Sure.
Keyboard Maestro Version 9.2
macOS Big Sur Version 11.5.2 (20G95)
Safari Version 14.1.2 (16611.3.10.1.6)
Google Chrome 92.0.4515.159 (x86_64)

Both of my machines have Intel CPU.

sorry for stupid question but where I can rename workspaces? I remember that in previous versions there was a "Rename" button. But in v2.89 I can't find it. I know I can choose a custom name when adding a new Workspace but can't figure out how to rename existing ones. :man_facepalming:

As the names of the Workspaces are what Keyboard Maestro uses to recall the window there isn’t a “rename” as such. You can make an unlimited number of new ones and delete as many as you want but the window positions are linked to whatever name you originally gave the workspace.

The previous “rename” feature didn’t actually rename it replaced one of the 12 Workspaces with a new one.

But it’s a good point that you should be able to rename and keep the data. I will do that!

In the meantime you could Restore a Workspace, make a new Workspace name and resave each window to the new named Workspace. If I were you I’d keep the A,B,C ones for a couple of days and wait for the update.

This is what’s interesting about uploading a Macro - others will use it slightly differently to me. But that’s also what makes this an interesting thing to do. :grinning:

Thanks for being the Beta tester!