I am following extensios porting guide for 45 Extension (ESModule) | GNOME JavaScript
I found the InjectionManager part and tried the given example.
Based on the example, I tweak my code as below.
import St from 'gi://St';
import { Extension, InjectionManager } from 'resource:///org/gnome/shell/extensions/extension.js';
import * as UnlockDialog from 'resource:///org/gnome/shell/ui/unlockDialog.js';
export default class ControlBlurExtension extends Extension {
constructor(metadata) {
super(metadata);
this._injectionManager = new InjectionManager();
}
enable() {
this._settings = this.getSettings();
// Overriding a method with an *arrow function*
this._injectionManager.overrideMethod(UnlockDialog.UnlockDialog.prototype, '_updateBackgroundEffects',
originalMethod => {
return () => {
const themeContext = St.ThemeContext.get_for_stage(global.stage);
let BRIGHTNESS_VALUE = this._settings.get_double('brightness');
let SIGMA_VALUE = this._settings.get_int('sigma');
for (const widget of this._backgroundGroup) {
const effect = widget.get_effect('blur');
if (effect) {
effect.set({
brightness: BRIGHTNESS_VALUE,
sigma: SIGMA_VALUE * themeContext.scale_factor,
});
}
}
originalMethod.call();
}
});
}
disable() {
this._injectionManager.clear();
this._settings = null;
}
}
However, the code is not working and I have two concerns
- I did not understand what is
originalMethod.call()
function is for - in the return function,
for (const widget of this._backgroundGroup) {
is it the rite way calling this._backgroundGroup?
Any help is much appreciated. Thanks