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

I love that you found those edge cases with the window location. I do keep my dock on the right and can never keep it from overlapping just slightly. Now I know why!

At first blush, I thought Ventura Stage Manager might supersede Desktop Spaces; but to the contrary, it seems the two work together quite nicely: An In-Depth Look at macOS Ventura Stage Manager


2023-03-13 Update: macMac has an newer Stage Manager video: The Comprehensive Guide To Mac Stage Manager. If you want to give Stage Manager a try, I recommend watching both videos.

@_jims Have you upgraded to Ventura?

I did last week and now the "move window n space" macros aren't working.

I can move spaces with Cntl-arrow, or with Cntrl-Cmd # -- but the move window scripts reposition the arrow, then change spaces, but the window doesn't move.

Any troubleshooting thoughts? I'm on MacOS 13.0, and KM version 10.2

Hi @blfarris; yes I have. I'm currently using 13.1 Beta (22C5033e) with Intel Macs. Are you using an M1?

I've not seen this problem, but I have tweaked a few of the subroutines and have been testing them for several weeks.

It could be related to and embedded AppleScript, but that's only an educated guess based on other issues I've seen with Ventura.

Later this week I'll send you a DM with a few updated subroutines. I'm confident that we'll be able to get this resolved.

OK, I just restarted the computer and it seems to be working fine now ¯_(ツ)_/¯

Naming Desktop Spaces

Note: This is not exactly on-topic for Jim's macro set, the primary topic of this thread. But it is, I believe, relevant to the larger topic of how to manage Desktop Workspaces effectively, in this case by using names instead of numbers. So this is, perhaps, a discussion of a future feature of Jim's macros, one which some people want but which he hasn't been able to implement.

Hi Nick,

I, too, used to use Stickies, they just seemed conceptually like the right thing, but Apple's Stickies really don't do the job -- if you have to reboot the Stickies will all open back up on the first Desktop, which is not what you want.

I was working on KBM macros to attempt to reposition each Sticky onto the right Desktop (I was stuck on how to identify each Desktop where there wasn't already a sticky there -- I could do it manually but it took a while). Then I found the free app CurrentKey (also called CurrentKey Stats because the author focussed a lot of features on collecting and displaying statistics on how much time you spent in each app on each Desktop). CK does the job wonderfully (except that I would like names longer than 16 characters, but that's a quibble).

CurrentKey even lets you assign hotkeys to each desktop. And, like Stickies, when you rearrange the order of the Desktops, the names move too, so the names stay with the content. Numbers, like in Apple's Mission Control or Jim's system here, don't do that, which is why I will avoid numbers for anything. I could not remember whether my KBM desktop was 15, 16, or 17, etc., especially not when I rearranged the desktops to keep the ones I am currently working on together, which is a hugely useful feature of Desktops that I didn't want to give up.

Based on my own experience, I believe the limitation of numbers is one of the prime reasons that Desktop Workspaces hasn't been more popular.

For me, I have over 20 Desktops, so it was pretty impossible to find hotkeys in any consistent pattern with letter mnemnonics for the content of each desktop, which didn't also accidentally typo into inadvertent things like closing all windows of the current app without saving.

So I made a KBM menu system front end to CK that took care of that. One hotkey brings up the Desktop names menu and a second keystroke, just a mnemonic letter, chooses the Desktop to go to. (I've posted the macro for how to automatically get a Return after the single keystroke to choose the Desktop from KBM's Prompt With List menu.) I can rearrange the order of the Desktops and even rename them on the fly and the system keeps up automatically.

I started writing a tutorial of how to set up this whole thing that was hoping to promote as a way to actually get Desktop Workspaces to fulfill the promise they have hinted at for over a decade (and maybe turn some of the people complaining on various Apple forums on to KBM). And then, unfortunately, the author of Current Key, Spencer Daily, withdrew it from the App Store because he lacks the time and resources to support the latest versions of MacOS (and because he recently became a father).

Right now, the only way to get CurrentKey is to follow Spencer Daily on Twitter. Every few months or so he announces that he will make Current Key available briefly on the App Store, or you can ask him to do so and when there are a few people in the queue he'll make it available for a couple of days.

So my tutorial languishes because I really don't want to promote a method that relies on an App that is no longer available. What's the point in that? Instead I have started working on ways to duplicate the Desktop Management features of Current Key (I don't care about the statistics). Whether it will integrate with Jim's system here, I don't know yet. As I've mentioned, key requirements for me are:

  • Long names (there's an old app out there that allows you to assign names to Desktops of up to three letters, but it patches Mission Control so you have to turn off System Integrity Protection to install it)
  • Rearrange Desktops and have the names follow (Stickies does this)
  • Change names on the fly (don't have to dig into code just to change a Desktop name)
  • Mnemonic menu access that doesn't care about renaming
  • Scales to my 20+ Workspaces

The big limitation for me of Jim's system, even with his extension to it described in Workspaces in Mission Control Desktop Spaces - Questions & Suggestions - Keyboard Maestro Discourse, is that both the Desktop Workspace names and Desktop order have to be hardcoded in KBM macros, you can't change them on the fly to suit what you're working on without having to dig into the KBM macro definitions.

As you have perhaps discovered with Stickies, you can change the name of a Desktop by changing the text of the Sticky, and when you rearrange the order of the Desktops, the Stickies follow along so there's nothing to update.

I had a correspondence with Spencer Daily after he withdrew CurrentKey and he told me that the core of the Desktop Space management was that he created invisible/hidden app windows on each Desktop, where the title of the window was the name of the space. So, just like you do with Stickies, bringing the appropriate window to the fore automatically changes the Workspace, without having to hack Mission Control.

In my current work-in-progress, I'm not worried about hiding the app windows. Instead I'm trying to allow there to be windows from a variety of apps, e.g., Notes, TextEdit, Typora. The key to whether an app can be used the way I want is whether, unlike Stickies, if the system shuts down, it restarts with the app windows on the right desktops, so the desktops can keep their names.

It's a complicated system, I'm not a professional software engineer, and I don't have a lot of time to devote to it, but I'm making progress.

Let me know if you're interested.

1 Like

Hi @August. It's not that I haven’t been able, it's that I have never tried; and as I replied to @nickwild above, I have no plans to add this capability.

For my workflow, this is not a limitation. Using the OP macros, I'm able to easily move windows to/from any of my 16 Desktop Spaces (regardless of space number/proximity), thus I have no need to rearrange the spaces. In fact, since I have a history of ergo pain from mouse overuse, I create macros that leverage the keyboard. Space rearrangement incudes mouse gymnastics that are particularly unappealing to me.


@August, based on this post and several of your others, it's clear that you have a different workflow with respect to spaces. I think it safe to say that this macro set will never be a helpful tool for you. But as we all know, the real beauty of Keyboard Maestro is that custom automations can be purpose-built and it seems that you are making good progress doing just that.

Dear community,
I'm using this macro in Ventura. I've 2 Desktops but when I try to move then window to a different desktop it says that the Desktop doesn't exist. It's valid between 1 to 2 and vice-versa.

I'm not a programmer and it's difficult to me to analyse this.

Any idea why this is happening?

BS

Hi, @bsilvamm. I'm the one that created and shared this macro set. It works fine with Ventura; in fact I'm using the latest beta: Ventura beta 13.3 (22E5219e).

I suggest you go to the top of this thread and scroll down to the Installation section. If any of the steps are skipped, the macros will not work as expected.

After confirming your set-up, please report back. If you are still having difficulty I'll do my best to help you troubleshoot further.

Hi @_jims
Thanks for your quick reply!

I've done all the steps (I think) and the same error occurred. The 2nd desktop is an external screen, could it be the issue?

BS

Yes, It should be related to the the external display. I've created another space in macbook display and it works fine.

I don't have an external display, so unfortunately I won't be able to test your configuration. However, if you give me two bits of information, I might be able to help:

1. Keyboard Shortcuts Settings

Please share a screenshot of your Keyboard Shortcuts for Mission Control. Here's are mine (Ventura System Settings):

2. WhichSpace Indication

When you are using the Desktop Space on your external monitor, what number is indicated by WhichSpace in the mac menubar? Likewise, when you switch spaces on your MacBook, what numbers are indicated?

When I'm on Mac's screen shows 1 on both Mac and external. When I'm on the external display both shows 3 (I've have 3 spaces now). I think you went directly to the point...

My keyboard shortcuts are:

BS

Okay, now I'm curious about this setting:

For me, it doesn't matter since I don't have an external display. But for you it would matter. What is it now? And if this is now on, turn it off, reboot, and then try the macros again.

It was turned on.

I turned it off and the space doesn't exist.

I've turned it again on, log out, log in and the issue remains.

Okay, @bsilvamm, after replying above, I remembered that I had an old monitor collecting dust. I dug it out and connected it to MacBook Pro; I was pleasantly surprised that it still worked. :grinning:

Here's what I observed...

Displays have separate Spaces : ON

  • When I invoked Mission Control (for me, four-finger swipe up on my trackpad), on my MBPro built-in display, Desktops 1–16 were indicated in the top bar of Mission Control. On the external display, I saw only Desktop 17 (one that got automatically created). The mac menubar was on both displays, and on both, WhichSpace indicated the number for the Desktop Space active for the built-in display.

  • I deleted one space on the built-in so that I could attempt to use the macro set to navigate and move windows to Desktop Space 16 (now on the external display). My tests confirmed your observations, @bsilvamm. After this test (and some others mentioned in the next bullet), I'm almost certain that this is a macOS limitation.

  • From Desktop 15 on my built-in display, I could not move to Desktop 16 using my macros, the System Settings Keyboard Shortcut (⌃⌥⇧⌘6) or even the trackpad gesture. (I also tried using BetterTouchTool which has similar Desktop Spaces capability. It also failed.)

  • The only way I could switch from Desktop 1–15 (built-in) to 16 (external) was by opening an app (I used Pages) on the external, leaving it open, then from Desktop 1-15 activating Pages. (I used Spotlight, but I think any method could be used, e.g., the Dock, etc.) Bear in mind that this just switched to Desktop 16 on the external display; it didn't have anything to do with moving windows. I'm not sure if that is even possible (using a Desktop Spaces mechanism), but if anyone would know, @August might. He's pushed the limit and uses spaces on multiple monitors, but I do know that he has run into some challenges.

  • Interestingly, when I did switch to Desktop 16 by activating Pages, WhichSpace did indicate 16 in the menubar. (Major props to the WhichSpace developer, George Christou!) Since the menubar is effectively cloned on both displays, the 16 appeared on both displays. This isn't ideal, but again I'm sure this is a macOS issue, not a WhichSpace shortcoming.

Displays have separate Spaces : OFF

  • The mac menubar was only displayed on the built-in monitor. This alone probably makes this setting a show-stopper, but I went ahead and tested.

  • When I invoked Mission Control (again, for me, four fingers swiped up on my trackpad), on my MBPro built-in display, Desktops 1–16 were indicated in the top bar of Mission Control (so Desktop 16 was automatically added. On the external display, I saw the same list, 1–16. So it appears that macOS treat the footprint of the built-in display and the external display as one large Desktop Space. I was hoping that the Displays have separate Spaces setting caused a different effect (a non-segregated series of spaces), but that's obviously not the case. So, to me, this seems to be a worthless setting.


But wait, there is a possible solution...

So, @bsilvamm, if you want to move windows from your built-in monitor to your external, I suggest you do this outside the context of Desktop Spaces. Here are three possibilities:

  1. Go to this StackExchange page and scroll down to the section that begins with: There is yet another option that's completely free and requires no third-party app

    I tested this method with Ventura, and it worked as expected with my external display.

  2. Use BetterSnapTool. I tested the following configuration and it worked as expected,

  1. Use BetterTouchTool. I also tested the following configuration, and it also worked as expected.

One big advantage of BetterSnapTool and BetterTouchTool vs the method described in 1. is that the same Keyboard Shortcut can be used to move a window to the external or back to the built-in. BetterSnapTool and BetterTouchTool are inexpensive, $3 and $10, respectively, and the latter is available in a Setapp subscription. With BetterTouchTool, you have much more flexibility regarding triggers (e.g., the window move could be initiated by gesture on the trackpad).

2 Likes

Am I reading that hotkey correctly as Alt+PowerButton?

I don't think I would have ever considered that the power button could be a hotkey.

@_jims
Wow, great analysis. Thank you for the time dedicated to this issue.
I've tried Magnet (similar functionalities to BetterSnapTool) and BetterTouchTool. For me it seems Magnet works better since it resizes automatically the windows. BetterTouchTool is indeed more flexible and can use the same trigger to move between monitors but doesn't work well to resizes windows (probably because the monitors have different resolutions).

This solution works for me.

Once again thank you. I've searched for help/share in several forum but this is where the spirit of sharing and mutual help is better.

BS

3 Likes

Hi @August. No, here that icon represents esc. Like you, I've seen ⎋ used to represent the power button.

@bsilvamm, you're welcome!

Good to know. I'll pass that along to others that use multiple monitors. I know Moom is wildly popular; I wonder if it also automatically resizes windows. (@griffman, do you know?)