Automatically saves and restores accents, GTK, shell theme, icons, cursors themes for light and dark modes. shortcut to toggle mode
Note: Binary files aren't shown on the web site. To see all files, please download the extension zipfile.
| Version | Status |
|---|---|
| 13 | Active |
| 12 | Inactive |
| 11 | Rejected |
| 10 | Inactive |
| 9 | Rejected |
| 8 | Rejected |
| 7 | Rejected |
| 6 | Rejected |
| 5 | Rejected |
| 4 | Rejected |
| 3 | Rejected |
| 2 | Rejected |
| 1 | Rejected |
====================================================================== AppearanceKeeperExtension – Settings Management ====================================================================== 1. Initial Version ------------------ In the original version, the constructor directly called `this.getSettings()` to initialize `_settings`: constructor() { this._manager = null; this._settings = this.getSettings(); } Then, `enable()` passed `_settings` to the manager: this._manager = new AppearanceKeeperManager(this._settings); The idea was to centralize access to the extension’s settings. 2. Reviewer Suggestion ---------------------- The reviewer recommended removing the constructor call and calling `this.getSettings()` directly in enable(): this._manager = new AppearanceKeeperManager(this.getSettings()); This approach follows standard GNOME Shell best practices, where `getSettings()` is provided by the extension and centralizes access to its settings. 3. Issue Encountered ------------------- Applying this correction as-is caused the following error: TypeError: this.getSettings is not a function Explanation: - `this.getSettings()` is only available if the instance is properly initialized by GNOME Shell via init()/enable(). - If the constructor is called or the instance is created in a test context, `getSettings()` does not exist yet, causing the TypeError. 4. Final Solution ----------------- To fix this issue while staying close to the reviewer’s recommendation, we defined our own `getSettings()` method inside the class, with a cache to ensure `Gio.Settings` is only created once. This method is called only in enable(). Final code used: export default class AppearanceKeeperExtension { constructor() { this._manager = null; this._settings = null; // cached for reuse } enable() { this._manager = new AppearanceKeeperManager(this.getSettings()); this._manager.start(); } disable() { if (this._manager) { this._manager.stop(); this._manager = null; } } getSettings() { if (!this._settings) { this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell.extensions.appearance-keeper' }); } return this._settings; } } Advantages of this approach: - Prevents the TypeError in all contexts (GNOME Shell, tests, imports). - Follows the reviewer’s idea by centralizing settings access. - Simple, maintainable, and compatible with GNOME Shell 48+.
1. Is this a bad upload? because you removed the `prefs.js`. 2. You get that error because you didn't extend the default class. Please read the [Port Guide 45](https://gjs.guide/extensions/upgrading/gnome-shell-45.html#extensionutils) for that. So, you should remove line 25-32 `extension.js` and replace 7 line `extension.js` with: ```js export default class AppearanceKeeperExtension extends Extension { ``` Don't forget to import the `Extension`: ```js import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; ``` Also, please join the GNOME Matrix channel. You can ping me there and show me the repo diff before sending the package here if you want. You will get a much faster response if you do that. We have a very friendly group of devs there. Don't hesitate to ask any questions: - [GNOME Extensions Matrix Channel](https://matrix.to/#/#extensions:gnome.org) - IRC Bridge: irc://irc.gimpnet.org/shell-extensions
1) is intended , not really usefull and i am tyred... 2) make the changes import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; export default class AppearanceKeeperExtension extends Extension { constructor() { this._manager = null; this._settings = null; } enable() { this._manager = new AppearanceKeeperManager(this.getSettings()); this._manager.start(); } disable() { if (this._manager) { this._manager.stop(); this._manager = null; } } } But this error: ReferenceError: must call super constructor before using 'this' in derived class constructor so this code work: import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; export default class AppearanceKeeperExtension extends Extension { _manager = null; _settings = null; enable() { this._manager = new AppearanceKeeperManager(this.getSettings()); this._manager.start(); } disable() { if (this._manager) { this._manager.stop(); this._manager = null; } } } it is ok ?
ok, i have found: import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; export default class AppearanceKeeperExtension extends Extension { constructor(metadata) { super(metadata); this._manager = null; this._settings = null; } enable() { this._manager = new AppearanceKeeperManager(this.getSettings()); this._manager.start(); } disable() { if (this._manager) { this._manager.stop(); this._manager = null; } } }
Yes, the last one is ok.
Wonderfull, thank you!