I'm building an automated wallpaper updater that fetches images from an API and sets them as desktop wallpaper on macOS Tahoe. The automation uses AppleScript combined with database manipulation to ensure wallpaper applies to all spaces.
Current implementation (via Apple Shortcuts):
wallpaper_path="$1"
osascript -e "tell application \"System Events\" to tell every desktop to set picture to
POSIX file \"$wallpaper_path\""
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "UPDATE data SET space=NULL
WHERE space IS NOT NULL;" 2>/dev/null
killall -HUP Dock
Issue
- First run: Works perfectly - sets wallpaper on all spaces/desktops, "Show on all spaces" is ON
- After first run: "Show on all spaces" automatically toggles OFF in System Settings
- Second run onwards: New wallpaper only updates on the active space, inactive spaces show old wallpaper
Expected: "Show on all spaces" should remain ON after programmatic wallpaper changes
Actual: System Settings automatically disables it, breaking subsequent updates
Tested workarounds (all failed):
- UPDATE data SET space=NULL to clear per-space entries
- Using every desktop instead of current desktop in AppleScript
- killall Dock vs killall -HUP Dock vs killall -USR1 Dock
- Clearing space_id entries from pictures table
- Running DELETE FROM pictures WHERE space_id IS NOT NULL before setting
The database manipulation doesn't prevent macOS from automatically creating per-space entries and disabling the "Show on all spaces" toggle.
Question: Is there a way to programmatically set wallpaper while preserving the "Show on all spaces" setting on macOS Tahoe?
Environment:
- macOS: Tahoe (latest)
- Architecture: Apple Silicon
- Use case: Daily automated wallpaper updates via Shortcuts