Skip to content

Instantly share code, notes, and snippets.

@piousdeer
Last active July 12, 2023 23:37
Show Gist options
  • Save piousdeer/1899b0b06a143af787528f4624ba3f0f to your computer and use it in GitHub Desktop.
Save piousdeer/1899b0b06a143af787528f4624ba3f0f to your computer and use it in GitHub Desktop.
Load newly installed GNOME extensions without restarting GNOME: run this script in Looking Glass (Alt+F2 and type 'lg')
const ExtensionUtils = imports.misc.extensionUtils;
const FileUtils = imports.misc.fileUtils;
const { ExtensionType } = ExtensionUtils;
(async function () {
let perUserDir = Gio.File.new_for_path(global.userdatadir);
const extensionFiles = [...FileUtils.collectFromDatadirs('extensions', true)];
const extensionObjects = extensionFiles.map(({dir, info}) => {
let fileType = info.get_file_type();
if (fileType !== Gio.FileType.DIRECTORY)
return null;
let uuid = info.get_name();
let existing = this.lookup(uuid);
if (existing) {
log(`Extension ${uuid} already installed in ${existing.path}. ${dir.get_path()} will not be loaded`);
return null;
}
let extension;
let type = dir.has_prefix(perUserDir)
? ExtensionType.PER_USER
: ExtensionType.SYSTEM;
try {
extension = this.createExtensionObject(uuid, dir, type);
} catch (error) {
logError(error, `Could not load extension ${uuid}`);
return null;
}
return extension;
}).filter(extension => extension !== null);
for (const extension of extensionObjects) {
// eslint-disable-next-line no-await-in-loop
await this.loadExtension(extension);
}
}).call(Main.extensionManager);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment