Switch to Previous Desktop Space

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 do 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

Thanks Jim,

That looks really interesting! Unfortunately, it’s for Catalina and Big Sur and I am on Mojave.

August

Hi @_jims, I've been making some progress.

I have been unable to find that WhichSpace.app has any kind of API, programmatic access by AppleScript, JavaScript, KBM, or whatever, to read the desktop number or get notification when the desktop changes. Do you know of any?

Meanwhile, it turns out that CurrentKey will call a specific AppleScript script every time the Desktop changes, no matter what method you use to change.

This is documented for CK at https://spencerdailey.com/2021/03/19/setup-banner-notifications-that-will-tell-you-the-name-of-the-space-you-just-moved-into/

So here is my modification of Spencer's script to report not only the current desktop, but also the previous.

As you can see from the debugging comments in the script, I tripped over the two different path syntaxes for AppleScript and the shell. The path hardcoded into the script is also the directory where ck.scpt lives, the default location in CK for the script.

Here's what I get as a Notification at the upper right of my screen, when I change from one desktop to another:
Screen Shot 2022-02-07 at 11.11.33 AM

As a Proof of Concept, at this point I have the name of the previous desktop name (Room name in CK terms) available when this AppleScript is triggered.

My next step is to modify the script to save the previous name so that I can read it when I need it, i.e. when triggered by my Previous Desktop hotkey.

One think I really like about CK is the naming of the Rooms/Desktops with meaning, and the other, magic for me, is that when I manually rearrange the order of the desktops, the names follow along, which gives me the freedom to rearrange the spaces in whatever order works for on my current task and the names and contents stay the same.

Yes, I use it throughout the macros that can be downloaded at Desktop Spaces • Macros for Navigation and Window Management.

tell application "System Events" ¬
to tell process "WhichSpace" ¬
to set temp to (title of menu bar items of menu bar 1)
return item 1 of temp

In my macros, that's all I use and need from WhichSpace, however...

If you really want to dig into this, you might find the following interesting:
[feature request] command line app · Issue #25 · gechr/WhichSpace

In that thread, you’ll see reference to davidpurnell/SpaceInfo: A command line app which returns MacOS spaces & display info

1 Like

Hi August

In a totally unrelated question, I am wondering how your friend is doing?

Did he finish the books? Is there a link to purchase?

I am also curious about his context switching as it relates to productivity for both you and him

Can you share how the experience has been?

To my knowledge, Rob is still working on the books.

As for me, it is incredibly useful to be able to have separate desktops on my Mac for different contexts. Right now I'm on my KBM desktop, for general use, forumm browsing, brainstorming, etc. When I'm deep into a macro that is taking some AppleScript or JavaScript testing and research, etc., I may dedicate a couple more desktops to those functions as well. I have a desktop devoted to Facebook, sometimes with six or more windows, another for healthcare and insurance, again with several ToDo lists and browser windows.

Since I was a teenager I've had a fantasy of a well equipped shop with woodworking tools, metalworking tools, and lots of different workbenches for various projects that could in various stages of completion.These days I'd add a couple of 3D printer stations, etc. In a way, my multiple desktops are form of that. I don't have to put everything away that I'm actually in the middle of to be able to take care of something else that comes up.

image

2 Likes