Go library to check whether the system is headless
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example/isheadless
LICENSE
README.md
isheadless.go
isheadless_test.go
isheadless_test_windows.go
isheadless_windows.go

README.md

IsHeadless

This little Go package provides a function isheadless.IsHeadless() bool. This function tells whether the Go program is running in a headless environment.

Examples

On Windows, isheadless.IsHeadless() always returns false. (Note that this is not correct as it ignores the edge case of running on Windows 10 IoT Core headless.)

On all other systems, isHeadless.IsHeadless() returns false if an environment variable named DISPLAY exists. The behavior is the same as with Java's java.awt.GraphicsEnvironment.isHeadless(). That is:

  • If DISPLAY is unset or set but empty, IsHeadless() returns true.
  • If DISPLAY is set and non-empty, IsHeadless() returns false.

Limitations

  • Currently, this function always returns false on Windows. The fact that Windows 10 IoT Core can be headless is ignored and unsupported.
  • Currently, this function does not support Android. On Android, it will always return true, no matter whether this is headless Android or "normal" Android.
  • Currently, this function always inspects the DISPLAY variable on all other operating systems, assuming X11 or an equivalent. This is wrong on those operating systems which provide a UI through means independent of a DISPLAY environment variable.