Why doesn't my gschema added to dconf after enablnig my extension

Hello there,
I’m new in extension development, I’ve created an extension and I want to save some preferences in gsettings, so I created a <extension-root>/schemas/org.gnome.shell.extensions.my-extension.gschema.xml

And this is my file:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
  <schema id="org.gnome.shell.extensions.my-extension" path="/org/gnome/shell/extensions/my-extension/">
    <key name="gtk-light" type="s">
      <default>"Adwaita"</default>
    </key>
    <key name="gtk-dark" type="s">
      <default>"Adwaita-dark"</default>
    </key>
    <key name="icon-light" type="s">
      <default>"Adwaita"</default>
    </key>
    <key name="icon-dark" type="s">
      <default>"Adwaita"</default>
    </key>
    <key name="shell-light" type="s">
      <default>"Default"</default>
    </key>
    <key name="shell-dark" type="s">
      <default>"Default"</default>
    </key>
  </schema>
</schemalist>

Then I compiled it:

$ glib-compile-schemas schemas/
$ ls schemas 
gschemas.compiled  org.gnome.shell.extensions.my-extension.gschema.xml

Disabling, re-enablig extension, logging out and logging back in and even restarting doesn’t change dconf (nor gsettings) :frowning:

Am I missing something?

Schemas are only looked up in specific paths (like /usr/share/glib-2.0/schemas).

Shell extensions are (usually) not installed system-wide, so you must specify the path to the schema:

$ gsettings \
  --schemadir = ~/.local/share/gnome-shell/extensions/my-extension/schemas \
  get org.gnome.shell.extensions.my-extension frobnicate

That’s also the reason the getSettings() convenience method exists - you cannot simply create the settings object with

new Gio.Settings({schema_id: 'org.gnome.shell.extensions.my-extension'});

if the schema isn’t installed globally.

2 Likes

Uh, thank you so much! I literally spent hours trying to figure out why my schema wasn’t getting added to dconf. I thought that was the reason why my extension wasn’t working. I assumed that GNOME would automatically add it to the global dconf and then my extension would read it from there. It seems that all the other extensions installed from the extension manager work in this way. Now I understand that these are two different things.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.