MACROS: Desktop Spaces • Macros to Improve Navigation and Window Management, v2.0

Not wanting to read the entire thread :), is this about moving windows across displays? If so, Moom can resize them or not as part of its “move window to display” command.

For saved layouts, they’re obviously saves and restored at what we size they were.

-rob.

2 Likes

Thank you @_jims for this macro. When you originally posted it I thought "how could anyone manage so many desktops" so I never tied it. When Stage Manager came out I started using it to manage my workspaces. I spent some time but found Stage Manager so unruly I gave up. Looking for a better solution I finally downloaded your macro on Desktop Spaces. I don't know how I got along without this macro. It was easy to settle into a workflow with this system and it is probably my favorite KBM macro. Five desktops is about the max my feeble mind can manage :crazy_face:

1 Like

Hi, @cyoungers. Thanks for the comment. I'm glad you are finding the macro set useful.

If you want to give Stage Manager another try, you might want to check out my earlier post where I included links to two macMost videos. (I added that second one today.) For my personal use, however, Stage Manager just hasn't stuck.

Ha, ha; I have several memorized, but when I forget, I use this palette as a reminder. The items on the left remind me of the main apps and the ones on the right are macros that I use to set up various work contexts in the 16 desktop spaces.

1 Like

A trivial but perhaps useful note…

"…macOS does not provide… a visual indication of the Desktop number."

No, but it does allow the assignment of different desktop images to different spaces. This strikes me as an elegant, unobtrusive solution.

It's easy enough to edit images to provide information, but I find it sufficient just to use different images. After a few hours, I unconsciously recognize them and always know what space I'm working in. I don't have to look for it or think about it – I just know.

1 Like

Good point, @commiepinko. I leverage that too.

WhichSpace provides both visual indication of the Desktop Space as well as a means to retrieve the number in a macro (via AppleScript).

Keyboard Maestro Version 11+ Required

I've updated the OP with Version 2.0 of Desktop Spaces • Macros to Improve Navigation and Window Management:

Summary of Improvements

  • Forty-three of the fifty-eight macros in this macro group are included in a palette. This palette is displayed using one of the macros in this group, ➜ Desktop Spaces - Show Palette of Macros, that includes a Show Palette of Macros action. By default, the palette can be displayed using ⌃D. Keyboard Maestro Version 11 provides a new feature that allows such palette to have an individual style. This feature has been used to optimize the appearance of the palette for this macro group. Previously the much less flexible Conflict Palette was used.

  • The macro Go to Previous Desktop uses a new Keyboard Maestro Version 11+ trigger When the active space changes. This new trigger enables more robust tracking of Desktop Space changes that are not keyboard-driven (i.e., via trackpad gestures or Mission Control interaction). Previously the The focused window changes was used; it didn't always fire when needed and fired many times when it was not needed.

  • Version 2.0 of this macro group includes many other improvements detailed below.

macro: Go to Application Desktop

  • Added a Title to the Prompt With List

macro: Go to Previous Desktop

  • Uses the new Keyboard Maestro Version 11+ trigger: When the active space changes (replacing the The focused window changes).
  • Changed ⌃⌥Return to display the Previous Desktop Space in large text (replacing a notification).
  • Added option to generate a sound when the space is changed. Note that the volume can be changed or the action can be disabled.

macro: Move Application Window to Current Desktop

  • The click-and-hold is done using absolute position because, during testing, it was found that with some applications front window top-left corner did not work as expected. Note: Thus far, this does not seem to be an issue if the application is already in the active Desktop Space, therefore the absolute position adjustment has not been made in macros: Move Window Left, Move Window Right, and Move Window to Previous Desktop.
  • For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.

macro: Move Window Left a Desktop

  • For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.

macro: Move Window Right a Desktop

  • For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.

macro: Move Window to Previous Desktop

  • For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release, changed from 1.0 to 1.5.

macro: sub—Activate an App and Wait Until It Is Ready

  • Removed the Front Window Check and the corresponding variable local_Null FrontWindowName.
  • When an About menu is not found, a dialog is generated (replacing a notification). The dialog includes an Edit button which enables a quick method to open this subroutine so that the application can be added to the local_MissingAboutMenuItem variable.

macro: sub—Get DesktopNo

  • Removed the local__Notification Level subroutine parameter as it is no longer needed since macro Go to Previous Desktop was changed to use Keyboard Maestro Version 11+ trigger When the active space changes (replacing trigger The focused window changes).
  • Moved the WhichSpace AppleScript to a Until action (Timeout set to 5 seconds). The approach previously was to run the AppleScript and then Pause 0.2 seconds.
  • If WhichSpace is not running, added a check that the user has been logged in for at least 2 minutes so that the WhichSpace not running dialog does not appear during mac boot up or user login.

macro: sub—Get DesktopNo_prev

  • Removed the parameter local__DefaultDesktopNo_prev.

macro: sub—Go to Desktop N

  • When attempting to move to a Desktop Space that does not exist, alert using large text (replacing a notification).

macro: sub—Move Window to Desktop N

  • Takes no action if local__TargetDesktopNo matches the curent DesktopNo.
  • For the Pause after the click-and-hold, changed from 0.2 to 0.5; for the Pause before the mouse release changed from 1.0 to 1.5.

macro: sub—Type Keystroke for Switch to Desktop N

  • Removed the otherwise notification since a failure to move to a non-existent Desktop Space is handled in the macro sub—Go to Desktop N.

Thanks @_jims for updating this! I followed your instructions on my M1 Mini and all went well.

When I sit down at a Mac that doesn't have these macros installed if feels broken!

1 Like

Hi @_jims
It's been long time I've been contemplating to start using your macro and today I've finally tried. I've followed all the user guidance you provided to the spot, however I always get this beautiful big notification that says that the mentioned desktop space doesn't exist (it does!). I've went through the comments and tried not using the numpad, but the actual keyboard on the Mac with the numbers - no luck.
My Setup - MB Air M2, MacOS Sonoma, multiple displays (standard MB Air + 49'' Samsung display if it makes difference) and each has desktop space and stage manager enabled.
Thanks in advance for any feedback/idea of what could be wrong.
Stan

Hi, @stanivanov. Sorry that you are having a problem getting the macro installed and configured.

Sorry, I'm not following this comment. Please elaborate.

Coincidentally, I just installed this macro set on a MBPro M1 and was pleased to see that it ran without a hitch.

Multiple physical displays could be an issue, but I have no way to test that configuration.

Do your Settings match the following?

Again, I can't test this, but I suggest you try on and off for Displays have separate Spaces.


If you want to simplify the problem, I suggest that you limit your Mission Control Desktop Spaces to the MBAir built-in monitor and see if you can get the macro set running as expected. (You may disagree, but IMO, Desktop Spaces provide the most benefit when using the relatively small laptop displays.)


Also, via a DM, I'll send you a simple diagnostic macro that you can use to help diagnose the problem.

Hi Jim,
thank you for your quick reply, the macro you sent provides the output I am expecting. i.e.

:red_circle: Display Accessed Variables - 1 -

:o: local_DesktopNo [3]
I have tried the grouping windows by application, even though I don't like it, so it's like yours, however, I get the same result - Desktop 3 doesn't exist.

Am I running the Macro correctly? While on a window, i.e. Safari - Ctrl.D - and then Ctrl+CMD+3 for example... I have tried also clicking on the palette..same error message.
The result is also the same when not connected to ext. display.

BTW the reason for separate spaces in my case is to use it for work when presenting my screen :slight_smile:

That's not required.

That's good!


When you are viewing Desktop Space 1, press ⌃⌥⌘3. Does Desktop Space 3 appear?

If not, refer to the OP configuration instructions, specifically the macOS Mission Control Shortcut keys.

Yep, the combo changes to space3. I have also tried to disable all my other macros, just to be sure it's not some shortcut conflict.
All the subroutines are disabled, I assume that's normal?
image
And last thing also which tried and didn't work as well is the sub-Type Keystroke for Switch.. I'm not sure the simulation works, as when I say try action for example to switch to Desktop 3, it doesn't do anything, but when I actually press the combo it works.
Thank you for already investing quite some time with me. Let me know if there's any other way to figure out why it doesn't work

Hi @_jims and everyone following the posts.
After couple of good hints from Jim, we were able to make the macro work.
I believe that in my case the problem was using the external keyboard with numpad keys which didn't behave in the same way as the normal numerals on the keyboard.
In order to get the macro working properly, I had to redo the shortcuts in the MacOS settings with the numerals on the keyboard (and not the numpad) and now it works just perfect, also with the external keyboard, but using the numerals.

Jim - any way to get this working also with the numpad keys?

Further - the Macros work fine with external monitors, however where each monitor has own desktop space (I assume the reason behind could be the different resolution?).

Here the setup and what does and does not work - MB Air (Desktop 1), Ext Monitor (Desktop 2 and Desktop 3). Moving an app between the Desktops 2 and 3 works, but from ext monitor to MB Air - does not. Within the MB Air - if you create additional spaces/desktops - the movement throughout works just fine. In general moving along spaces on same monitor/device works fine, but not between them.

Thank you Jim for making this so user friendly, but please mention in your guidance the use of the numpads when creating the shortcuts in the MacOS settings.
Cheers, Stan

Thanks for the update, @stanivanov.

Yes, you are free to change the hot key triggers for the macros in the group. More on that below, but first I want to emphasize that it is important to configure the macOS Keyboard Shortcuts as indicated in the OP.

Yes, modifier+key(s) are called Hot Keys in Keyboard Maestro, whereas macOS refers to them as Keyboard Shortcuts.

The hard-and-fast rule stated above actually has more flexibility than stated. If a user is very careful, the macOS Keyboard Shortcuts can be deviate from the instructions, but the changes must be duplicated in the macro sub—Type Keystroke for Switch to Desktop N. These changes are only recommended if you have a conflict with one of the macOS Keyboard Shortcuts, e.g., if you have used one of the modifier+keys combination for one of your Keyboard Maestro macros.


Okay, now back to the macro hot key triggers for the group macros...

In the screenshot below, you have complete flexibility to change the hot keys in the green vertical rectangle. (There is no need to add hot keys to the macros that currently have None.)

The macros indicated by the blue vertical line are included in the palette displayed below. Note that this palette, itself, is completely optional, but the macros displayed on the palette will be used.

If you do change one or more of the green box macros hot keys AND you plan to use the palette (by default, triggered with ⌃D), then I suggest that you change the corresponding macro name(s) indicated with the red arrow(s).

Note that the palette has two purposes. It is: 1) used to as one method to trigger the underlying macros, and 2) serves as a quick-reference so that future macro invocations can be done directly.



1 Like

Hi @_jims That works flawlessly. It's been a while since I needed to configure new macros or play with existing ones, but your explanation was very easy to understand and make it happen. As I work usually with just one additional space/desktop on the screen, I just need to change 4 Macros ("to 2", "to 3" and "2","3").
All works like a charm. Thanks again and keep up the good work!

Stan

1 Like

Thanks for the update, @stanivanov.

Great to hear!

Yes! Moreover, if you want to use the palette, it can be easily adjusted thanks to the awesome Show Palette of Macros action used in the macro: ➜ Desktop Spaces - Show Palette of Macros.

For example, if you just have three Mission Control Desktop Spaces, then you can disable the unneeded palette macros as depicted here (red bars):


2023-12-07 23.21.33@2x


Then when you press ⌃D, macro ➜ Desktop Spaces - Show Palette of Macros will run, and the following palette will appear.



And, yes, the ⌃D hot key trigger can also be changed.

I've just upgraded to version 2, and now it plays the Pop sound every time I change desktop.

While the action (in the Go to Previous Desktop macro) is called "Optionally change the volume or disable this action", there's nothing in the README to indicate where this is, and KM's search facility leaves a lot to be desired. It took me about 15 minutes to find and I ended up grovelling through the XML to find which macro it was in — could you add a note to the README to let people know where they can turn it off?

I also greatly preferred the old way of displaying errors in notifications rather than giant text — KM fills the width of the screen with it, and on a 32" display it really is like it's screaming "YOU DID IT WRONG!" rather than the discreet notification that we used to have.

I think, rather than changing back to notifications, a better fix would be for KM to allow the user to cap the maximum size for large text (I've just disabled the messages for now, since it beeps anyway :slightly_smiling_face:)

Hi, @Unikitty. Thanks for the feedback.

@Unikitty, sounds like you managed to disable the Pop sound; albeit it was a bit of a challenge.


For the benefit of others that might also be upgrading to v2.0...

First, why was this Pop sound added in Version 2.0?

I've chosen to make the following change within the System Settings:

With the above change, switching from space-to-space seems much snappier; but since there is far less visual feedback when the space changes, I like the feedback that the Pop sound provides. However, I suspected that some might not like this enhancement, thus I attempted to clearly document it. However, as @Unikitty pointed out, it's not in a README per se.

So, how do I make the change?

The Pop sound change and others are documented in OP within the Version History. Here's what you will find above in that section.


Once you select the Go to Previous Desktop macro, the change is again documented in the macro header comment, and the specific action is set off in a group that is labelled and colored orange.

1 Like

Ohhh this was driving me nuts too - I have all sound notifications turned off on my machine, and I couldn't figure out WHERE the sound was coming from. Having to wade through the entire discussion was a bit of a slog!
Anyway, thanks for a very useful macro set!
Cheers...

Hi, @seishonagon; I suspected that this change might not appeal to everyone, thus I mentioned it in the Version History.

Personally, I've lowered the volume (1/4 full volume). I find the subtle sound useful when Reduce Motion is enabled. See the previous post for more information.

If using the forum via a browser on your computer, you can press Shift+# to more quickly traverse a thread.

You're welcome. Glad you are finding it useful.