MCPcopy Create free account
hub / github.com/material-shell/material-shell / getExtensionSettings

Function getExtensionSettings

src/utils/extension_utils.ts:7–41  ·  view source on GitHub ↗
(
    extensionUUID: string
)

Source from the content-addressed store, hash-verified

5 * Returns null if it cannot be found.
6 */
7export function getExtensionSettings(
8 extensionUUID: string
9): Gio.Settings | null {
10 const extension = Main.extensionManager.lookup(extensionUUID);
11 if (!extension) return null;
12
13 try {
14 // Check if the schema exists in the global schema source.
15 // This may work for system extension, but not for custom extensions.
16 return new Gio.Settings({
17 schema_id: extension.metadata['settings-schema'],
18 });
19 } catch (_) {
20 // Ignore
21 }
22
23 try {
24 // Check if we can find the schema in the extension's own schema source.
25 // This may work for custom extension, but not system extensions.
26 const source = Gio.SettingsSchemaSource.new_from_directory(
27 extension.path + '/schemas/',
28 Gio.SettingsSchemaSource.get_default(),
29 false
30 );
31 return new Gio.Settings({
32 settings_schema:
33 source.lookup(extension.metadata['settings-schema'], false) ||
34 undefined,
35 });
36 } catch (_) {
37 // Ignore
38 }
39
40 return null;
41}

Callers 2

Calls 2

get_defaultMethod · 0.80
lookupMethod · 0.65

Tested by

no test coverage detected