Skip to content

fix(macOS): handle wallpaper detection without GUI - #2559

Closed
niu541412 wants to merge 1 commit into
fastfetch-cli:devfrom
niu541412:fix-headless-wallpaper
Closed

fix(macOS): handle wallpaper detection without GUI#2559
niu541412 wants to merge 1 commit into
fastfetch-cli:devfrom
niu541412:fix-headless-wallpaper

Conversation

@niu541412

Copy link
Copy Markdown
Contributor

On headless macOS, querying NSScreen connects to WindowServer and may abort. Check for a GUI session first, while keeping the plist and SQLite fallbacks available.

@CarterLi

CarterLi commented Sep 2, 2026

Copy link
Copy Markdown
Member

On headless macOS, querying NSScreen connects to WindowServer and may abort

What do you mean by abort? The entire displayserver_apple.c is talking to WindowServer. If connecting to WindowServer will abort the program it has been aborted in the Display module. No?

Not sure about the headless macOS either. The CI runner is a headless environment IMO and clearly has no real displays, but it can also have a virtual display.

https://github.com/fastfetch-cli/fastfetch/actions/runs/33584489343/job/100105891321

@niu541412

niu541412 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

This is probably due to the interface on older versions of macOS not handling this case properly.


fastfetch -s Wallpaper
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
2026-09-01 15:27:10.483 fastfetch[96727:71308553] *** Assertion failure in -[NSWorkspace desktopImageURLForScreen:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.61.100/AppKit.subproj/NSWorkspace.m:2216
2026-09-01 15:27:10.484 fastfetch[96727:71308553] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: screen != nil'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff37dcbf3b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff5f124942 objc_exception_throw + 48
2 CoreFoundation 0x00007fff37dd1b22 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff39f1a9f0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 AppKit 0x00007fff35bc2041 -[NSWorkspace desktopImageURLForScreen:] + 380
5 fastfetch 0x000000010b727b71 ffDetectWallpaper + 100
6 fastfetch 0x000000010b6ff4c2 ffPrintWallpaper + 65
7 fastfetch 0x000000010b68ba09 ffPrintJsonConfig + 4670
8 fastfetch 0x000000010b67f997 main + 314
9 libdyld.dylib 0x00007fff5fd3f015 start + 1
10 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

@CarterLi CarterLi closed this in 0286209 Sep 3, 2026
CarterLi added a commit that referenced this pull request Sep 3, 2026
Also moves NSWorkspace method to the last method to try

Fixes #2559
@CarterLi

CarterLi commented Sep 3, 2026

Copy link
Copy Markdown
Member

Please test 0286209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants