Skip to content

Commit

Permalink
feat: detect Dark/Light mode-change on enable #79
Browse files Browse the repository at this point in the history
  • Loading branch information
neuromorph committed Oct 3, 2024
1 parent b92c5a2 commit 1c20cab
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions openbar@neuromorph/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,7 @@ export default class Openbar extends Extension {

// Update styles on Dark/Light mode change
if(callbk_param == 'color-scheme') {
this.gtkCSS = true;
StyleSheets.saveGtkCss(this, 'enable');
AutoThemes.onModeChange(this);
this.onModeChange();
return;
}

Expand Down Expand Up @@ -986,6 +984,12 @@ export default class Openbar extends Extension {
}, timeout);
}

onModeChange() {
this.gtkCSS = true;
StyleSheets.saveGtkCss(this, 'enable');
AutoThemes.onModeChange(this);
}

updateBguri(obj, signal) {
// console.log('update bguri called for signal ', signal);
// If the function is triggered multiple times in succession, ignore till timeout
Expand Down Expand Up @@ -1432,7 +1436,17 @@ export default class Openbar extends Extension {
}, 2000);
// Set initial bguri as per color-scheme
const bguri = this._settings.get_string('bguri');
if(bguri == '') this.updateBguri();
if(bguri == '')
this.updateBguri();
else {
// If mode was changed (by script/extension) while OpenBar was disabled (screen-lock),
// detect mode-change and update styles
let bguriDark = this._bgSettings.get_string('picture-uri-dark');
let bguriLight = this._bgSettings.get_string('picture-uri');
let currentBgUri = (this.colorScheme == 'prefer-dark') ? bguriDark : bguriLight;
if(bguri != currentBgUri)
this.onModeChange();
}

// Update calendar style on Calendar rebuild through fn injection
const obar = this;
Expand Down

0 comments on commit 1c20cab

Please sign in to comment.