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"?>
  <schema id="org.gnome.shell.extensions.my-extension" path="/org/gnome/shell/extensions/my-extension/">
    <key name="gtk-light" type="s">
    <key name="gtk-dark" type="s">
    <key name="icon-light" type="s">
    <key name="icon-dark" type="s">
    <key name="shell-light" type="s">
    <key name="shell-dark" type="s">

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.


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.