Sonoma: Is It No Longer Possible to Fetch Wallpaper File Names?

Under Ventura, desktop wallpaper image names were stored in a sqlite database at ~/Library/Application Support/Dock/desktoppicture.db. This file is no longer being used under Sonoma.

I have a process I built that fetches the desktop image file names and displays them, either as a service, or on the desktop. I do this because I have many photos I've taken, and I like to know which one I'm viewing so I can make edits if necessary. I set these images across five spaces and have them randomly change every hour. I tried using AppleScript but it would not pull the file names.

A few people have pointed me to ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist. However, on my system, this only reveals the source folder and not the image name itself. On one of my Macs, it shows 64 items, even though I have only five spaces!

Is there a way to fetch the image file names under Sonoma? Will Sequoia make this easier or harder?

Is there a way to fetch the image file names under Sonoma?

There’s no supported way to get a list of all the wallpaper images. The best you can do is get the current image, using either NSWorkspace or Apple Script. However, even that has its challenges, as discussed on this thread.

You program previous relied on an implementation detail. These things can and do change over time, which is why your code broke.

Will Sequoia make this easier or harder?

The only way things are going to get easier is if we add a full-featured API for this. I’m not aware of any such API in macOS 15 beta. Feel free to file an enhancement request for that.

In the absence of a proper API, things are likely to get harder as Apple continues to improve security and privacy on macOS.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Dang.

Thank you, Quinn. I think this dashes my hope of creating a small utility. I'm not a Swift coder and AppleScript hasn't worked for this kind of thing for some time. Apple's built-in "everyman tools" such as Automator, Shortcuts and AppleScript aren't really meant to get this deep, even with shell scripting included.

I suppose I could request this type of enhancement, as there are a lot of similar queries online, but I suspect it's too insignificant for Apple to spend time and resources on.

{Sigh}. I long for the days of HyperCard. :)

Hi, don't have Sonoma, but following script works for me in Sequoia 15.1.

I used two shell commands to get the trick done, pgrep and lsof. lsof is nice to figure out which process is using a file. So, I made a folder with a few pictures, played with the wallpaper settings and found that the pictures were used by process WallpaperImageExtension. And because lsof also works the other way, which files a process is using, we can use WallpaperImageExtension to figure out the path(s) to the desktop pictures. pgrep is only used in the script to reliably find the pid of WallpaperImageExtension process, which changes after each reboot.

the handler returns a list of aliases. The number depends on the number of spaces in use. Handler only looks for pictures, so it returns 'missing value' if the wallpaper was set to a movie.

on getDesktopPicture()
	tell application "Finder"
		if desktop picture is missing value then return missing value 
		if class of desktop picture is document file then return {dp} 
		set folderPath to POSIX path of (desktop picture as alias)
		set pid to do shell script "pgrep WallpaperImageExtension"
		set lsofResult to do shell script "lsof -p " & pid & " | grep -o '" & folderPath & ".*$'"
		set {filePaths, fileList} to {(every paragraph of lsofResult) as list, {}}
		repeat with f in filePaths
			set end of fileList to (f as POSIX file as alias)
		end repeat
		return fileList
	end tell
end getDesktopPicture
Sonoma: Is It No Longer Possible to Fetch Wallpaper File Names?
 
 
Q