diff --git a/darkMode@linuxedo.com/files/darkMode@linuxedo.com/5.8/applet.js b/darkMode@linuxedo.com/files/darkMode@linuxedo.com/5.8/applet.js index e9faf6714f3..a5c95510b95 100644 --- a/darkMode@linuxedo.com/files/darkMode@linuxedo.com/5.8/applet.js +++ b/darkMode@linuxedo.com/files/darkMode@linuxedo.com/5.8/applet.js @@ -178,6 +178,28 @@ MyApplet.prototype = { this.dark_mode_switch.connect('toggled', Lang.bind(this, this.on_change_theme)); this.menu.addMenuItem(this.dark_mode_switch); + // Listen for suspend/resume signals + this._loginManager = Gio.DBusProxy.new_for_bus_sync( + Gio.BusType.SYSTEM, + Gio.DBusProxyFlags.NONE, + null, + 'org.freedesktop.login1', + '/org/freedesktop/login1', + 'org.freedesktop.login1.Manager', + null + ); + this._prepareForSleepId = this._loginManager.connect('g-signal', (proxy, sender, signalName, params) => { + if (signalName === 'PrepareForSleep') { + // The signal sends `true` on suspend, `false` on resume. + let sleeping = params.get_child_value(0).get_boolean(); + if (!sleeping) { + // Waking up from suspend, re-check the theme. + this.allow_auto_mode_change(); // Adicionado para permitir a mudança após suspensão + this.change_mode_automatically(); + } + } + }); + // Update the UI this.set_dark_mode(this.enable_dark_mode); this.refresh_themes(); @@ -186,6 +208,19 @@ MyApplet.prototype = { } }, + on_applet_removed_from_panel: function() { + // Disconnect the suspend signal listener + if (this._prepareForSleepId) { + this._loginManager.disconnect(this._prepareForSleepId); + this._prepareForSleepId = 0; + } + // Remove the timer + if (this.timer) { + Mainloop.source_remove(this.timer); + this.timer = null; + } + }, + on_applet_clicked: function (event) { this.dark_mode_switch.setToggleState(this.enable_dark_mode); this.menu.toggle();