Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/detection/wallpaper/wallpaper_apple.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
#include "common/apple/osascript.h"

#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
#import <AppKit/AppKit.h>

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];
Expand Down Expand Up @@ -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;

Expand Down
Loading