#
hs.spaces
This module provides some basic functions for controlling macOS Spaces.
The functionality provided by this module is considered experimental and subject to change. By using a combination of private APIs and Accessibility hacks (via hs.axuielement), some basic functions for controlling the use of Spaces is possible with Hammerspoon, but there are some limitations and caveats.
It should be noted that while the functions provided by this module have worked for some time in third party applications and in a previous experimental module that has received limited testing over the last few years, they do utilize some private APIs which means that Apple could change them at any time.
The functions which allow you to create new spaes, remove spaces, and jump to a specific space utilize hs.axuielement
and perform accessibility actions through the Dock application to manipulate Mission Control. Because we are essentially directing the Dock to perform User Interactions, there is some visual feedback which we cannot entirely suppress. You can minimize, but not entirely remove, this by enabling "Reduce motion" in System Preferences -> Accessibility -> Display.
It is recommended that you also enable "Displays have separate Spaces" in System Preferences -> Mission Control.
This module is a distillation of my previous hs._asm.undocumented.spaces
module, changes inspired by reviewing the Yabai
source, and some experimentation with hs.axuielement
. If you require more sophisticated control, I encourage you to check out https://github.com/koekeishiya/yabai -- it does require some additional setup (changes to SIP, possibly edits to sudoers
, etc.) but may be worth the extra steps for some power users.
#
Submodules
#
API Overview
Variables - Configurable values
MCwaitTime
Functions - API calls offered directly by the extension
activeSpaceOnScreen activeSpaces addSpaceToScreen allSpaces closeMissionControl data_managedDisplaySpaces data_missionControlAXUIElementData focusedSpace gotoSpace missionControlSpaceNames moveWindowToSpace openMissionControl removeSpace screensHaveSeparateSpaces setDefaultMCwaitTime spaceDisplay spacesForScreen spaceType toggleAppExpose toggleLaunchPad toggleMissionControl toggleShowDesktop windowsForSpace windowSpaces