--- gsettings.c	2017-11-06 14:11:37.561816000 +0100
+++ gsettings_new.c	2017-11-06 14:08:42.736514000 +0100
@@ -33,6 +33,8 @@
 
 #include "strinfo.c"
 
+#include <syslog.h>
+
 /**
  * SECTION:gsettings
  * @short_description: High-level API for application settings
@@ -1132,6 +1134,78 @@
 }
 
 /* Internal read/write utilities {{{1 */
+
+/* write schema id to backend for relocatable schemas */
+static gboolean
+g_settings_write_sid_to_backend (GSettings *settings)
+{
+  gboolean success = FALSE;
+  gchar *path = NULL;
+
+  gchar *gsschemapath = NULL;
+  gchar *gsschemaid = NULL;
+  gchar *retgsschemaid = NULL;
+  GVariant *gvsid = NULL;
+
+  syslog(LOG_ERR, "gsettings.c wsidtb");
+
+  // is this a relocatable schema?
+  // g_settings_schema_get_path returns const gchar * or NULL
+  gsschemapath = g_strdup (g_settings_schema_get_path(settings->priv->schema));
+
+  // get schema-id property from gsettings object
+  gsschemaid = g_strdup (g_settings_schema_get_id(settings->priv->schema));
+
+  // schema path is NULL -> relocatable schema
+  if(NULL == gsschemapath && NULL != gsschemaid) {
+
+    syslog(LOG_ERR, "gsettings.c wsidtb reloc schema found");
+
+    // create new path + key
+    path = g_strconcat (settings->priv->path, "schema-id", NULL);
+
+    // try to read "schema-id"
+    gvsid = g_settings_backend_read (settings->priv->backend, path, G_VARIANT_TYPE_STRING, FALSE);
+
+    if(NULL != gvsid) {
+      // try to get the schema-id string
+      retgsschemaid = g_variant_dup_string (gvsid, NULL);
+
+      syslog(LOG_ERR, "gsettings.c wsidtb, read schema-id: %s", retgsschemaid);
+
+      // free gvar
+      g_variant_unref(gvsid);
+    }
+
+    if(0 == g_strcmp0 ((const char *) gsschemaid, (const char *) retgsschemaid))
+    {
+      syslog(LOG_ERR, "gsettings.c wsidtb schema-id to write already written");
+    }
+    else
+    {
+      syslog(LOG_ERR, "gsettings.c wsidtb trying to write schema-id");
+
+      // write schema-id to backend
+      // g_settings_backend_write() frees the new GVariant, as it is floating
+      success = g_settings_backend_write (settings->priv->backend, path, g_variant_new_string (gsschemaid), NULL);
+
+      syslog(LOG_ERR, "gsettings.c wsidtb reloc schema: %s:%s %d", gsschemaid, path, success);
+
+    }
+
+  }
+
+
+  // no problem if a pointer is NULL
+  g_free (gsschemapath);
+  g_free (gsschemaid);
+  g_free (retgsschemaid);
+
+  g_free (path);
+
+  return success;
+}
+
 static gboolean
 g_settings_write_to_backend (GSettings          *settings,
                              GSettingsSchemaKey *key,
@@ -1144,6 +1218,16 @@
   success = g_settings_backend_write (settings->priv->backend, path, value, NULL);
   g_free (path);
 
+  // if we don't want to write the "schema-id" drirectly
+  // write it implicitly
+  // params are NOT gchar
+  // only for reloc schema
+  if(success && (0 != g_strcmp0 ("schema-id", (const char *) key->name)) &&
+    (NULL == g_settings_schema_get_path(settings->priv->schema)))
+  {
+    g_settings_write_sid_to_backend (settings);
+  }
+
   return success;
 }
 
@@ -2278,6 +2362,10 @@
 
       delayed = G_DELAYED_SETTINGS_BACKEND (settings->priv->backend);
       g_delayed_settings_backend_apply (delayed);
+
+      // assume that the write was successful, write schema-id
+      syslog(LOG_ERR, "gsettings.c apply()");
+      g_settings_write_sid_to_backend (settings);
     }
 }
 
