ReadonlydesktopThe "Desktop N" number Mission Control shows for this desktop. Mission Control only
numbers desktops, and numbers them across all displays in turn, so a second display's
first desktop can be "Desktop 3". (When there's only one desktop, Mission Control calls
it just "Desktop", but this is still 1.) null for a fullscreen space, or if the space
no longer exists.
ReadonlyexistsWhether the space still exists
ReadonlyidThe space's ID. macOS assigns these, and they last until the space is removed, so a
removed and re-added space gets a new ID. They may change when you log out or restart:
use uuid (with hs.screen.spaceForUUID()) to find a space again in a later session.
ReadonlyisWhether this is the space its screen is currently showing. Each screen shows one space at a time, so with several screens, several spaces are current.
ReadonlyisWhether this is the focused space: the current space of the screen with keyboard focus
ReadonlyscreenThe screen the space belongs to. Every space belongs to exactly one screen. null if
the space no longer exists, or its screen has been disconnected.
If "Displays have separate Spaces" is turned off, all screens share one set of spaces, which macOS attributes to the primary screen.
ReadonlytypeWhat kind of space this is: "desktop" for an ordinary desktop, "fullscreen" for a
fullscreen app (or two apps in Split View), or "unknown" for a kind of space this
version of Hammerspoon doesn't recognise. null if the space no longer exists.
ReadonlyuuidThe space's UUID, which macOS keeps across logins (it's how it remembers which space
is which). null if the space no longer exists, or if macOS hasn't given it one, which
it doesn't for the first desktop of a new user account.
Switches this space's screen to this space, by opening Mission Control and clicking it. Needs Accessibility permission.
A Promise that resolves once the screen is showing this space
Removes this desktop, by opening Mission Control and clicking its close button. Any windows on it move to another desktop on the same screen. Needs Accessibility permission.
Only desktops can be removed - not fullscreen spaces - and macOS won't remove a screen's only desktop, or the desktop the screen is currently showing.
A Promise that resolves once the desktop has gone, or rejects
A summary of the space, for JSON.stringify() and the Console
An object with the space's id, uuid, type, screen (its UUID),
The IDs of the windows on this space, front to back. Only ordinary windows are
included (not menus, panels, the menu bar, etc). Windows set to appear on every space are
included for every space. Hammerspoon can't make HSWindow objects for windows on other
spaces, which is why these are IDs.
An array of window IDs, empty if the space no longer exists
One space (a desktop, or a fullscreen app's space) on a screen.
Get these from a screen (
screen.spaces,screen.currentSpace), a window (window.spaces) orhs.screen(e.g.hs.screen.focusedSpace()); don't create them yourself. AnHSSpacealways reports the space's current state, so there's no need to fetch it again after something changes. If the space is removed,existsbecomesfalse, its other properties becomenull, and its methods reject.To move a window to a space, use the window's
moveToSpace().Compare spaces by
id, not with===: two lookups of the same space give two different objects.