Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions darkMode@linuxedo.com/files/darkMode@linuxedo.com/5.8/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down