Sydney Senior SRE/Sysadmin/Something.

Making GNOME-Shell plugins save their config

· by Robert Mibus · Read in about 1 min · (192 Words)
gnome linux

I’m working on a GNOME-Shell plugin that can show alternate timezones. As part of the plugin, I want it to remember what the user’s selected timezone is.

A good extension to pull apart seems to be the “System Monitor“.

The “short version” of the minimum you need to do is as follows…

Add a schema name to your metadata.json, eg:

"settings-schema": "",

(Replace “system-monitor” with a unique name for your own extension)

Create a schemas directory inside your extension’s directory, and create a file inside that called YOURSCHEMANAME.gschema.xml, eg.

Populate this with appropriate gschema magic; the system-monitor schema is pretty handy again here.

Inside your extension’s schemas directory, run:

glib-compile-schemas .

(Don’t miss the “.” :)

Download convenience.js┬áinto your extension’s directory.

Inside your extension.js, set up some new imports:

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

Somewhere during init() or enable(), you’ll want to grab a reference to your loaded schema object:

this._schema = Convenience.getSettings();

You can now get and set keys, eg. I’m using:




You probably should set up an actual preferences window… you can learn more about that at