Open anijatsu opened 3 years ago
@anijatsu Hey! Unfortunately Apple does not provide an API for this. In fact, all the Spaces functionalities are not officially supported by Apple and use private internal APIs.
Raised a suggestion via Apple's Feedback Manager for a new public API to become accessible. ID is FB9319058, in case anyone would want to follow in my steps.
Hi! There’s some hints around the internet about CGSCreateSpace/CGSTransactionCreateSpace/SLSTransactionCreateSpace
and the same for destroy in the private APIs, but they don’t seem to be available to link when building.
@kasper CGSSpaceCreate
works, even in macOS 12.2. requires a dock restart to show up (killall Dock
)
CGSSpaceCreate(CGSDefaultConnection(), 0, [
"type": 0, // 0 is CGSSpaceTypeUser (https://github.com/NUIKit/CGSInternal/blob/master/CGSSpace.h)
"uuid": UUID().uuidString as CFString,
] as CFDictionary)
other usage on GH:
https://github.com/avaidyam/Parrot/blob/6cf7ba419176c386ed8f18e838690a7272fe57ee/MochaUI/CGSSpace.swift (swift) https://github.com/avaidyam/DIYAnimation/blob/8d9c6713379ecabcd09e64c7cd74d631c530a685/DIYAnimation/Framework/Render%20API/RenderDisplay.swift https://github.com/jonas-mika/dotfiles/blob/477e7e0fb46b499cc03af06fcaf898adf08d97ca/.hammerspoon/hs/_asm/undocumented/spaces/internal.m https://github.com/a-soll/mac_window/blob/c4f578ecb3e7e5e84077171c12898e162d9251c5/source/space.c
@kaatt Hah, I was trying with the wrong order in the function name. Thanks! Obviously killing the Dock is not really something that Phoenix should do.
there may be an undiscovered/entitlement-gated function that makes the space show without killing dock. maybe you can expose an api to kill dock so its up to the user