Switch to Previous Desktop Space

Has anyone built a macro to switch to the previous desktop space?

So far my best alternative is to move the spaces next to each other and then do a 3-fingered swipe left and right on my laptop. But that's not as easy on my desk. And it's impossible to do while holding a window in motion to move it to the other desktop space.

I cannot find a KBM trigger for "Change Workspace/Desktop".

Current Key (free desktop management app) will call AppleScript when the desktop space is changed (Room Change Alerts – CurrentKey Stats) but it only tells the name of the new desktop space ("room" in CK) so that would have to be saved for every space change to know what the previous one is. (If you're with me so far, note that CK does not use the Mission Control Desktop numbers, it lets you assign text names to each desktop space and those are persistent if you rearrange the order of the desktops, hence a different term, "rooms".)

If there is no support in KBM for desktop space changes, I may try building it using AppleScript and CK, managed by KBM, but I'd rather have something closer to "off the shelf".

Any suggestions?

Thanks.

Hi @August. I've spend more time than I'd like to admit on Desktop Spaces.

If you have any questions after reading through this, feel free to let me know.

Thanks. I'll take a look. I, too, spend more time than...

I have a friend who is working on 14 books at once. He has a dedicated room in his house with several tabletops full.
Breszny working on multiple desktops

The only way I know how do use a similar workflow on a computer is with desktop spaces, and I've been addicted to them for years. (I know the guy who invented the concept on SCO UNIX in the mid-1980s, when they called it MultiScreens.)

I currently have 21 desktops, when I have my external monitor plugged in, and could add more. Unplugged, the first space of the external monitor disappears, I have 20 spaces, and I cannot add any more.

image

The Blank External desktop is the one that disappears. I got so frustrated with what OSX does to that desktop, going back and forth with an external monitor or not, that I dedicated the first screen on each display to being blank. I still use them, as scratch desktops, but I don't count on anything there being stable.

One thing I have discovered that is joyful in this environment is that the TextEdit is well integrated into desktop spaces. I can have multiple TE windows on multiple spaces and through reboots and crashes, they stay in the right space, even if they weren't saved. Other apps that succeed in keeping multiple windows, move them all to the first desktop space when rebooting.

First question:

Can the hotkeys for Left, Right, and Previous be changed? Of couse they can, It's KBM, but will that break things unexpectedly?

Ctrl+LeffArrow and Ctrl+Return take two hands because my keyboards don't have a Right Control key, only one on the left. I really want those commands to be things I can type one-handed.

Thanks.

Second question:

Can I extend this to more than 16 desktops? Do you have any idea how to add the required extra entries to System Preferences > Keyboard > Shortcuts > Mission Control?

Thanks

Theoretically yes, but I will say that I thought long and hard to pick logical key combinations while still avoiding conflicts with other system functions. Also, if you do change the Hot Keys, the optional palette will no longer correctly indicate the Hot Keys.

How about this? Try the above conflict palette, but change the Hot Key (to something one-handed) that displays it. It's currently Ctrl-S.

I designed the palette to minimize the required keystrokes. For example, to go to the Previous desktop, you can: 1) Press Hot Key to launch the conflict palette, 2) Type P.

As far as I know, this is a macOS limitation. (IMHO, Desktop Spaces are half-baked feature of macOS.) And since there is no macOS public API to change Desktop Spaces, these native shortcuts are required for the macros I shared.

On a related note, you might want to review this post: MACROS: Desktop Spaces • Macros for Navigation and Window Management v1.1

Control+S already is typeable one-handed, for me at least.

In my current menu, shown above with 21 desktop names, I use Option+Shift+Command+S, which I can also type with one hand. The metakey positons are slightly different on my desktop keyboard compared to my laptop, so each entry also is triggered by Control+Option+Shift+S so that my muscle memory works between the two keyboards. For my usage, it doesn't have to be a fast one-handed operation, but it has to be physically comfortable to do.

1 Like

I wonder how Current Key Stats (CKS) does it. CKS lets me define hotkeys for all 21 of my current desktops and, unlike the awkward, position-based system of OSX (Desktop 1, Desktop 2, ...), the hotkeys stay attached to the desktop even if I decide to rearrange the order of the desktops (which I can do with Drag-n-Drop in Mission Control).

Could be with private API's. I think I've read that this is a practice that Apple tries to monitor and restricts from the App Store.

Here's an Ask Different page where the Current Key author comments briefly about the API:

Because macOS API's are limited, the names stay in the app and don't show up in Mission Control.

desktop - How to name a deskop in mission control? - Ask Different.

I may be reading too much into it, but that sounds to me like he's using public APIs and has found a way to get them to at least most of what he wants.

Hi @August, it could be that the post is referring to some other API's—not sure.

@peternlewis's comment from Apr 2020 states that Apple does not make any of the Spaces API public. Maybe there's been a change since then, but I tend to doubt it.

1 Like

I doubt they are public APIs.

You could ask if the app is using public or private APIs.

I'm surprised its on the MAS if it is using private APIs, but who knows, Apple Review is a mysterious black box.

I did. And I got an answer.

His technique seems doable in KBM (but not by me, not any time soon anyway).

2 Likes

Does anyone have any ideas for how to create something like Spencer's "little invisible app windows"? That seems a steep learning curve for me.

<brainstorm on>
I've been thinking that I could create TextEdit windows where the doc title is the name given to the desktop workspace, all with a common prefix, so they show up together in lists of active TE windows. Either they are as tiny as they can be made and put off in a corner, or even outside the visible area, or they have the name and an icon or symbol, a background color, etc. so they become an identifier flag to let you know which desktop you are working in and maybe to identify the thumbnails that get displayed by Mission Control.

TextEdit is one of the few apps where open windows are restored after a reboot in their original desktops. Most apps reopen a single window and those that do reopen multiple windows often move them all to the first desktop. TE would thus, at least at first look, fill the requirement of changing desktops for you when you bring the appropriate window to the foreground.
<brainstorm off>

Comments?

Sorry, I can't help—that's beyond my pay grade!

But in another forum post I saw the following and noticed the mention of spaces. Maybe it's worth checking out.

Contexts - Radically simpler & faster window switcher for Mac