Posted on 12-29-2023 06:46 AM
Hey all! I have an issue that some of you can, hopefully, help with. Apple has made some changes to the way macOS handles screensavers and wallpapers over the last couple of iterations and, with Sonoma, I'm hitting a blocker when trying to deploy a policy to add an image and set the wallpaper to that image for all displays. This is how I currently have the policy setup:
I created a package that adds a folder containing the image to to the system library
I added the following script to run after the package was installed:
#!/bin/zsh
new_wallpaper_path="/Library/CompanyFolder/Company\ Wallpaper/Company_Wallpaper.png"
/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
I've executed the policy on my test machine successfully but when I had another user test for me, the package installed but the script failed with the following error:
Script result: Set: Entry, "AllSpacesAndDisplays:Desktop:Content:Choices:0:Files:0:relative", Does Not Exist
The plist file Sonoma uses for wallpaper prefs is:
~/Library/Application\ Support/com.apple.wallpaper/Store/Index.plist
The key that is being edited is:
<key>AllSpacesAndDisplays</key>
<dict>
<key>Desktop</key>
<dict>
<key>Content</key>
<dict>
<key>Choices</key>
<array>
<dict>
<key>Configuration</key>
<data>
all the datas
</data>
<key>Files</key>
<array>
<dict>
<key>relative</key>
<string>file:////Library/Company/Company%20Wallpaper/Company_Wallpaper.png</string>
</dict>
</array>
Is there a better way for me to approach this? Am I overthinking?
Our company is super tight when it comes to security and for something like wallpapers or screensavers I wouldn't be able to get a green light to use a 3rd party app or open sourced project without a pretty long and excruciating procurement process.
Thanks in advance! Hopefully this is simple enough. Since it works perfectly on my own machine, I feel like I am super close! maybe a small tweak. But even if I need a completely different approach, I'm game! In the past, this was so dang simple!
Posted on 12-31-2023 12:23 PM
What happens if you try the PlistBuddy command without the double quotes?
Posted on 01-02-2024 06:56 AM
I get the following result:
Script result: File Doesn't Exist, Will Create: AllSpacesAndDisplays:Desktop:Content:Choices:0:Files:0:relative
Invalid Arguments
I think that your right about the quotes, though, so thanks!
Posted on 01-02-2024 07:26 AM
I mean I think you were correct that the Syntax was incorrect, but fixing that just resulted in a slightly different error.