1

In system settings, under Wallpaper, there is a new toggle option to "Show on all Spaces". I'm looking for a way to set this option via shell in terminal since when a new wallpaper is set the switch toggles back to false.

wallpaper

I've tried diffing defaults before and after toggling the switch to see if there is some setting I have access to there, but no luck. Also looking into osascript and I am able to set the desktop picture there, but I haven't found a way to toggle that setting from osascript.

Edit: here's one way to do it, but it's less than ideal. I'd like to be able to set it without launching the application!

  tell application "System Events"
      tell application "System Settings"
          activate
      end tell
      delay 0.5
      tell process "System Settings"
          delay 0.5
          click menu item "Wallpaper" of menu "View" of menu bar 1
          delay 0.5
          click checkbox "Show on all Spaces" of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Wallpaper"
      end tell
      delay 0.5
      tell application "System Settings"
          quit
      end tell
  end tell

1 Answer 1

0

So I did a bit of digging and macOS Sonoma seems to use a new .plist file for wallpaper/screensaver related things, located at ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist.

You can edit this .plist to achieve what you're looking for.

  1. Go to System Settings > Wallpaper and make sure to set a wallpaper from a folder you added yourself and that "Show on all Spaces" is on.
  2. Enter the following in a terminal:
new_wallpaper_path="/path/to/wallpaper.jpg"; \
/usr/libexec/PlistBuddy -c "set AllSpacesAndDisplays:Desktop:Content:Choices:0:Files:0:relative file:///$new_wallpaper_path" ~/Library/Application\ Support/com.apple.wallpaper/Store/Index.plist && \
killall WallpaperAgent

GitHub issue that helped me figure this out: https://github.com/JohnCoates/Aerial/issues/1332

7
  • Thanks for digging into this! This seems closer to what I want to achieve. I'm already able to change the desktop photo with a bit of AppleScript: osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"${1}\" as POSIX file" I'm trying to toggle the "Show on all Spaces" feature within the terminal rather than manually in System Settings as you suggest here. I've been playing around with the Plist you've shared and so far it doesn't look like osx cooperates with modifying it and will just fallback to the default wallpaper :/
    – Jared Wyce
    Commented Nov 24, 2023 at 14:35
  • @JaredWyce If you need to do it in AppleScript, I don't think I can help as I've never used it. My method should work if you're willing to use bash/zsh to change the wallpaper. It'll keep the "Show on all Spaces" option set as long as it was set beforehand.
    – sumga13
    Commented Nov 26, 2023 at 2:26
  • If you really are looking for a way to "toggle" this "Show on all Spaces" option, and aren't ok with just setting it once manually and having it stay on (as long as you use my solution to change the wallpaper), that should still be possible. You can see how the setting affects the .plist by comparing it before/after ticking the setting. You can use this to convert the .plist into plain-text in a file named test.txt: plutil -p ~/Library/Application\ Support/com.apple.wallpaper/Store/Index.plist > test.txt
    – sumga13
    Commented Nov 26, 2023 at 2:36
  • your method would be perfect for me, except that after the first time I set a wallpaper that way, the .plist will revert back to Type: idle (with all desktops configured separately) instead of Type: individual (with a single desktop image) so I won't be able to change wallpapers in succession without having to manually flip the "Show on all Spaces" option again. Also, I've already looked at the before and after diff as you suggested in your second comment, and Sonoma adds a Configuration byte array which I don't think I'll be able to write the .plist myself with PlistBuddy
    – Jared Wyce
    Commented Nov 26, 2023 at 20:40
  • 1
    I now realize that another app I was using was modifying my wallpaper and untoggling "Show on all Spaces". Although I'm still left without a good solution that plays nice with that app for the time being, I will mark your answer as correct so that maybe it'll help someone else. Cheers
    – Jared Wyce
    Commented Nov 26, 2023 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .