private static void initialize() {
    if (isInitialized) {
      return;
    }

    synchronized (TouchbarSupport.class) {
      if (isInitialized) {
        return;
      }

      try {
        if (GraphicsEnvironment.isHeadless()) {
          LOG.info("touchbar disabled: the graphics environment is headless");
        }
        else if (!Registry.is(IS_ENABLED_KEY, true)) {
          LOG.info("touchbar disabled: registry");
        }
        else if (!JnaLoader.isLoaded()) {
          LOG.info("touchbar disabled: JNA library is unavailable");
        }
        else if (!Helpers.isTouchBarServerRunning()) {
          LOG.info("touchbar disabled: touchbar-server isn't running");
        }
        else {
          isEnabled = true;

          // read isEnabled from OS (i.e., NSDefaults)
          String appId = Helpers.getAppId();
          if (appId == null || appId.isEmpty()) {
            LOG.info("can't obtain application id from NSBundle (touchbar enabled)");
          }
          else if (NSDefaults.isShowFnKeysEnabled(appId)) {
            // user has enabled the setting "FN-keys in touchbar" (global or per-app)
            if (NSDefaults.isFnShowsAppControls()) {
              LOG.info("touchbar enabled: show FN-keys but pressing fn-key toggle to show app-controls");
            }
            else {
              LOG.info("touchbar disabled: show fn-keys");
              isEnabled = false;
            }
          }
          else {
            LOG.info("touchbar support is enabled");
          }
        }
      }
      catch (Throwable e) {
        LOG.error(e);
      }

      if (!isEnabled) {
        isInitialized = true;
        return;
      }

      try {
        NST.loadLibrary();
      }
      catch (Throwable e) {
        LOG.error(e);
        isEnabled = false;
      }

      isInitialized = true;
      enableSupport();
    }
  }
private static void initialize()