Search code examples
linuxgnomegnome-shell-extensionsgjs

gnome-shell 3.34 missing ExtensionUtils.extension property


I've written a GNOME shell extension for gnome3.30-3.32 using:

const ExtensionUtils = imports.misc.extensionUtils;
...

ExtensionSystem.disableExtension(ExtensionUtils.extensions['extension-uuid'].uuid);

Updating to 3.34 version, ExtensionUtils does not provide the 'extension' property, and I don't know to find the documentation about it.

How can I fix the issue?


Solution

  • The code you're looking for, the map of loaded extensions, is also a part of the ExtensionSystem module, whereas the ExtensionUtils module is mostly utilities for extension authors like GSettings and Gettext helpers.

    The functions you are looking for are a part of the class ExtensionManager in 3.34+. You can get the ExtensionManager instance from the Main import:

    // >= 3.34
    const Main = imports.ui.main;
    const ExtensionManager = Main.extensionManager;
    
    ExtensionManager.disableExtension(uuid);
    
    // <= 3.32
    const ExtensionSystem = imports.misc.extensionSystem;
    
    ExtensionSystem.disableExtension(uuid);
    
    
    // Handling both versions
    const Config = imports.misc.config;
    
    if (Config.PACKAGE_VERSION.split('.')[1] >= 34) {
        let manager = imports.ui.main.extensionManager;
    
        manager.disableExtension(uuid);
    } else {
        let extSystem = imports.misc.extensionSystem;
    
        extSystem.disableExtension(uuid);
    }
    

    Sources:

    You can use the branch selector on the left of the GitLab page to select the version, or the history button on the right to view a list of changes to a given file.