SamPom100
SamPom100

Reputation: 31

Getting the path of the current screen's wallpaper on macOS Sonoma

On previous macOS versions, Apple wrote Desktop image locations to

/Users/\<current-user\>/Library/Application Support/Dock/desktoppicture.db

However on macOS Sonoma this seems to have changed. desktoppicture.db no longer contains up to date information about the current wallpapers / their paths. Does anyone know where the new database is located?

I've been using these solutions for years:

How to get the path to the current workspace/screen's wallpaper on OSX?

Getting desktop background on Mac

and https://github.com/musically-ut/whichbg, which is a neat tool written in Swift

Update

found this github issue: https://github.com/JohnCoates/Aerial/issues/1332

but the plist looks like (using plutil -p)

"Displays" => {
        "37D8832A-2D66-02CA-B9F7-8F30A301B230" => {
          "Desktop" => {
            "Content" => {
              "Choices" => [
                0 => {
                  "Configuration" => {length = 292, bytes = 0x62706c69 73743030 d5010203 04050607 ... 00000000 000000ef }
                  "Files" => [
                    0 => {
                      "relative" => "file:///Users/me/Backgrounds/"
                    }
                  ]
                  "Provider" => "com.apple.wallpaper.choice.image-folder"
                }
              ]
              "Shuffle" => {
                "Duration" => [
                  0 => 97
                  1 => 10665824850173493248
                ]
                "Type" => "afterDuration"
              }
            }
            "LastSet" => 2023-11-30 04:16:17 +0000
            "LastUse" => 2023-11-30 04:16:23 +0000
          }

not sure how to get the path out of here, the previous db had it directly as a string

Upvotes: 2

Views: 2458

Answers (3)

Brad G.
Brad G.

Reputation: 811

I went down this rabbit hole recently trying to figure out how to get the description for the current aerial screensaver/wallpaper. The only place I could find the path was in the list of files opened by the WallpaperVideoExtension process:

> lsof -Fn -p $(pgrep WallpaperVideoExtension) | grep ".mov"
n/Library/Application Support/com.apple.idleassetsd/Customer/4KSDR240FPS/25A6CFB2-3570-4448-B114-244A4E454B7A.mov

Using that ID, you can look up the localizedNameKey for the wallpaper in in /Library/Application Support/com.apple.idleassetsd/Customer/entries.json, and then use that to grab the description from /Library/Application Support/com.apple.idleassetsd/Customer/TVIdleScreenStrings.bundle/$LANG.lproj/Localizable.nocache.strings.

Here's a bash script to do the whole rigamarole, and a little Mac menu bar app that displays the name of the current [aerial] wallpaper: https://github.com/bgreenlee/WallpaperInfo

Upvotes: 1

Trygve
Trygve

Reputation: 1407

Something that might be related...

Calling [[NSWorkspace sharedWorkspace] desktopImageURLForScreen:[[self display] screen]] on my XDR display which shows the Utah Monument Valley wallpaper results in a NSURL of:

NSURL * @"file:///System/Library/CoreServices/DefaultDesktop.heic"

The NSScreen is correct as it shows:

<NSScreen: 0x600003985920; name="Pro Display XDR"; backingScaleFactor=2.000000; frame={{0, 0}, {3008, 1692}}; visibleFrame={{0, 62}, {3008, 1605}}>

Something is broken in desktopImageURLForScreen under Sonoma 14.3 that worked fine in 14.2.

When I decode the "Configuration" item buried in com.apple.wallpaper, I get something like:

assetID = "100858D2-FE01-4B70-8E2D-3FCF20AFE6B5"

Upvotes: 1

AladdinHo
AladdinHo

Reputation: 21

There is no database that I know of. I was able to locate the current desktop photo by using “console” I filtered for BEGIN - IMAGE CACHE LOOKUP Leave it running, it will update with every wallpaper change.

Upvotes: 2

Related Questions