public static boolean setShowFnKeysEnabled(String appId, boolean val, boolean performExtraDebugChecks) {
    if (!isDomainExists(ourTouchBarDomain)) {
      final Map<String, Object> vals = new HashMap<>();
      vals.put(ourPerAppKey, new HashMap<>());
      createPersistentDomain(ourTouchBarDomain, vals);
      if (!isDomainExists(ourTouchBarDomain)) {
        LOG.error("can't create domain '" + ourTouchBarDomain + "'");
        return false;
      }
    }

    final Path path = new Path();
    path.myPath.add(new Path.Node("persistentDomainForName:", ourTouchBarDomain));
    path.myPath.add(new Path.Node("objectForKey:", ourPerAppKey));
    String sval = path.readStringVal(appId);
    final boolean settingEnabled = sval != null && sval.equals(ourShowFnValue);

    final String initDesc = "appId='" + appId
                            + "', value (requested be set) ='" + val
                            + "', initial path (tail) value = '" + sval
                            + "', path='" + path + "'";

    if (val == settingEnabled) {
      if (performExtraDebugChecks) LOG.error("nothing to change: " + initDesc);
      return false;
    }

    path.writeStringValue(appId, val ? ourShowFnValue : null);

    if (performExtraDebugChecks) {
      // just for embedded debug: make call of Foundation.invoke(myDefaults, "synchronize") - It waits for any pending asynchronous updates to the defaults database and returns; this method is unnecessary and shouldn't be used.
      sval = path.readStringVal(appId, true);
      final boolean isFNEnabled = sval != null && sval.equals(ourShowFnValue);
      if (val != isFNEnabled)
        LOG.error("can't write value '" + val + "' (was written just now, but read '" + sval + "'): " + initDesc);
      else
        LOG.error("value '" + val + "' was written from second attempt: " + initDesc);
    }

    return true;
  }
public static boolean setShowFnKeysEnabled(String appId, boolean val, boolean performExtraDebugChecks)