Introduction
Mission Control Desktop Spaces, a.k.a. Desktop Spaces, a.k.a. macOS virtual Desktops, can be very useful particularly when using a MacBook. Unfortunately, however, configuration and use of Desktop Spaces can be confusing especially when using three or more. The current macOS maximum is 16.
In addition, native macOS does not provide:
-
A visual indication of the Desktop number. Moreover, macOS does not include a public API to determine the Desktop number or to switch Desktop Spaces.
-
A quick method to switch between non-adjacent Desktops.
-
An efficient method to move windows to non-adjacent Desktops
The instruction and macros in this post will address these shortcomings and more.
Requirements
This macro group has two requirements:
-
Keyboard Maestro Version 11+
-
WhichSpace (a free, third-party menu bar application)
Differences/Improvements Versus Superseded Macros
This macro group supersedes all macros found in forum thread Desktop Spaces • Macros for Navigation and Window Management.
Expand for details
-
The macros will be installed in macro group: .sys Desktop Spaces. The group can be renamed, but it is recommended that the macro be kept together.
-
The group consists of 57 macros:
8 Primary Macros—4 for navigation and 4 for window movement:
- Go Left a Desktop
- Go Right a Desktop
- Go to Application Desktop
- Go to Previous Desktop
- Move Application Window to Current Desktop
- Move Window Left a Desktop
- Move Window Right a Desktop
- Move Window to Previous Desktop
7 Subroutine Macros:
- sub—Activate an App and Wait Until It Is Ready
- sub—Get DesktopNo
- sub—Get DesktopNo_prev
- sub—Go to Desktop N
- sub—Move Window to Desktop N
- sub—Put DesktopNo and/or DesktopNo_prev
- sub—Type Keystroke for Switch to Desktop N
42 Conflict Palette Macros
-
Due to the modular design:
-
The macros have been simplified.
-
The 8 primary macros and 7 subroutine macros can easily be used by other macros in the Keyboard Maestro library. Also, macro hot keys and underlying macOS keyboard shortcuts can now be easily changed (if the default configuration causes collisions with existing library macro hot keys and/or macOS keyboard shortcuts).
-
Deleting Previous Versions
Note: It is very important to delete older versions of these macros before completing the installation of Version 2.0.
If you previously installed any macros from this thread or thread Desktop Spaces • Macros for Navigation and Window Management, complete the following steps:
-
For the .sys Spaces macro group, rename it .sys Spaces-superseded. For the renamed group export it, then delete it.
-
For the .sys Desktops macro group, rename it .sys Desktops-superseded. For the renamed group export it, then delete it.
-
For the .sys Desktop Spaces macro group, rename it .sys Desktop Spaces-superseded. For the renamed group export it, then delete it.
In the unlikely event that it becomes necessary to view the macros deleted above, the exported groups can be imported, but only after installing Version 2.0 below.
Version History
Expand for details
v2.0 (2023-10-27) • Requires Keyboard Maestro Version 11+
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.
v1.1 (2022-04-06) • Requires Keyboard Maestro Version 10+
macro: Go to Previous Desktop
- Bug fix: local_dnPreviouslySaved was improperly determined.
macro: Move Window to Previous Desktop
- Removed an extraneous local_dnTarget Set Variable to Text action. No change to macro functionality.
macro: sub—Activate an App and Wait Until It Is Ready
- Added provision for applications that have a null %FrontWindowName%.
v1.0 (2022-03-21) Initial version • Requires Keyboard Maestro Version 10+
Installation
To install Desktop Spaces • Macros to Improve Navigation and Window Management, complete the following:
-
If necessary, using Mission Control, create multiple macOS Desktop Spaces.
-
For macOS Ventura+, configure System Settings > Desktop & Dock > Mission Control.
For macOS pre-Ventura, configure System Preferences > Mission Control.
-
For macOS Ventura+, configure System Settings > Keyboard > Keyboard Shortcuts > Mission Control.
For macOS pre-Ventura, configure System Preferences > Keyboard > Shortcuts > Mission Control.
Specifically, the macOS Mission Control Shortcuts should be configured as follows:
Switch to Desktop 1 to 9 --> ⌃⌥⌘1 to ⌃⌥⌘9
Switch to Desktop 10 to 16 --> ⌃⌥⇧⌘0 to ⌃⌥⇧⌘6
Note: Ideally the macOS Mission Control Shortcuts can be configured exactly as summarized above; however, if any of these shortcuts causes a conflict with an existing Keyboard Maestro hot key, the shortcuts can be customized providing the macro sub—Type Keystroke for Switch to Desktop N is similarly changed. If this becomes necessary, refer to the Type a Keystroke actions.
-
Optionally configure System Settings > Accessibilty > Display.
-
Click to download the following:
Desktop Spaces • Macros to Improve Navigation and Window Management v2.0.zip (143.0 KB)
-
Unzip the download and follow the instructions included in the enclosed _READ ME FIRST_ files.