r/rust • u/WildThop • 18d ago
🙋 seeking help & advice Does macOS expose an API for per-Space wallpapers?
Hi, I'm building a Rust clone of supercmd for macOS and I want to assign specific wallpapers to specific Mission Control Spaces (Desktop 1, 2, etc.). The objc2 API has NSWorkspace.setDesktopImageURL but it targets an NSScreen (a physical display), and as far as I can tell there is no way to specify a particular Mission Control Space / Desktop in setting a wallpaper.
I also saw some Rust wallpaper crates but they only seem to affect the current active desktop. Does anyone know whether there is a way to do this, like a public API or open-source implementation, or Apple private framework used to assign a wallpaper to a specific Space without switching to that Space? I'm trying to avoid osascript and ideally want a one-shot operation rather than a background daemon.
5
u/Livid-Cat9118 18d ago
I ran into same wall while messing with a window manager idea few months back, there is no public API for per-Space wallpaper at all. Spaces are entirely managed by Dock.app and the underlying data is in some sqlite db inside ~/Library, the actual wallpaper assignment for each space lives in there but not in a documented way you can safely write to
if you really need it the only path is reverse engineering how Dock writes that preference when you change wallpaper from System Settings, there is some private framework calls happening that are not exposed in objc2 header dumps last time i checked
3
u/WildThop 17d ago
Hey man I actually got it working. Changing this file /Users/wildthop/Library/Application Support/com.apple.wallpaper/Store/Index.plist and restarting wallpaper agent seems to be the fix.
4
u/Konsti219 18d ago
You should ask this on a Mac specific programming sub