Determine color (not image) of Desktop

If the user does not select a image for the Desktop, then (at least in High Sierra)


NSWorkspace.shared.desktopImageURL(for: NSScreen.main!)


returns something like


file:///System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane/Contents/Resources/DesktopPictures.prefPane/Contents/Resources/Transparent.tiff

which makes sense- a transparent tiff.


How do i determine the color the user selected for the Desktop?

Accepted Reply

ah, the data is in desktopImageOptions...


NSWorkSpace.shared.desktopImageOptions(for: NSScreen.main!)


returns a dictionary with


NSWorkspaceDesktopImageOptionKey[NSWorkspaceDesktopImageFillColorKey] = NSColor

Replies

What do you mean exactly by "color of the desktop" ? It is not necessarily a uniform color, so what do you expect ?


Is it the color of a specific pixel ?

ah, the data is in desktopImageOptions...


NSWorkSpace.shared.desktopImageOptions(for: NSScreen.main!)


returns a dictionary with


NSWorkspaceDesktopImageOptionKey[NSWorkspaceDesktopImageFillColorKey] = NSColor

i mean the color the user selected in System Preferences> Desktop & Screen Saver>Desktop, Custom Color...

Great, don't forget to close the thread.