diff --git a/src/detection/wallpaper/wallpaper_apple.m b/src/detection/wallpaper/wallpaper_apple.m index 63acae325c..06fe08250f 100644 --- a/src/detection/wallpaper/wallpaper_apple.m +++ b/src/detection/wallpaper/wallpaper_apple.m @@ -3,10 +3,17 @@ #include "common/apple/osascript.h" #import +#import #import const char* ffDetectWallpaper(FFstrbuf* result) { + CFDictionaryRef session = CGSessionCopyCurrentDictionary(); + bool hasGuiSession = session != NULL; + if (session) + CFRelease(session); + + if (hasGuiSession) { // Reliable for user-picked static images. NSURL* url = [NSWorkspace.sharedWorkspace desktopImageURLForScreen:NSScreen.mainScreen]; @@ -76,6 +83,9 @@ #endif + if (!hasGuiSession) + return "No active graphical session"; + if (ffOsascript("tell application \"Finder\" to get POSIX path of (get desktop picture as alias)", result)) return nullptr;