From 21c15c2ba00bc2a73dbba6759052a3619ac06889 Mon Sep 17 00:00:00 2001 From: Romain Date: Mon, 23 Mar 2020 15:04:39 +0000 Subject: [PATCH] Don't reset user's original theme on screen lock (Fix #5) --- src/modules/Themer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/Themer.js b/src/modules/Themer.js index 27d664e..560888b 100644 --- a/src/modules/Themer.js +++ b/src/modules/Themer.js @@ -18,6 +18,7 @@ this program. If not, see . const { extensionUtils } = imports.misc; const { Gio } = imports.gi; +const { main } = imports.ui; const Me = extensionUtils.getCurrentExtension(); const config = Me.imports.config; @@ -26,6 +27,8 @@ const { log_debug } = Me.imports.utils; const { Variants } = Me.imports.modules.Variants; +const State = new Map(); + /* The Themer communicates with the system to get the current theme or set a new @@ -52,7 +55,11 @@ var Themer = class { disable() { log_debug('Disabling Themer...'); this._stop_listening_to_theme_changes(); - this.reset_theme(); + // GNOME Shell disables extensions when locking the screen. We'll only reset the theme if the user disables the extension. + State.set('last_disabled_on_screen_lock', main.screenShield.locked); + if ( !State.get('last_disabled_on_screen_lock') ) { + this.reset_theme(); + } log_debug('Themer disabled.'); } @@ -84,7 +91,7 @@ var Themer = class { } reset_theme() { - this.set_variant('original'); + this.current = State.get('original_theme'); log_debug('Theme has been reset to the user\'s original variant.') } @@ -100,6 +107,9 @@ var Themer = class { _update_variants() { if ( this.current ) { this.variants = Variants.guess_from(this.current); + if ( !State.get('last_disabled_on_screen_lock') ) { + State.set('original_theme', this.variants.get('original')); + } log_debug('Variants updated: ' + this.variants); } }