Skip to content

christianhujer/isheadless

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

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.

About

Go library to check whether the system is headless

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages