Detect headless mode in gdscript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dodgyville

Is there a way to detect if we are in headless mode from within gdscript?

:bust_in_silhouette: Reply From: magicalogic

Yes it does.

OS.has_feature("Server")

Returns true if it is running on a headless server.

Perfection! Thank you

dodgyville | 2023-01-03 05:25

For Godot4 you need DisplayServer.get_name() == "headless"
or
!DisplayServer.window_can_draw(), depending on your use case…