import {Extension, InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
export default class CustomizeClockOnLockScreenExtension extends Extension {
enable() {
this._injectionManager = new InjectionManager();
this._injectionManager.overrideMethod(Main.screenShield, '_ensureUnlockDialog',
originalMethod => {
return allowCancel => {
const ret = originalMethod.call(Main.screenShield, allowCancel);
this._maybeModifyClock();
return ret;
};
});
this._maybeModifyClock();
}
disable() {
this._injectionManager.clear();
this._injectionManager = null;
}
_maybeModifyClock() {
const clock = Main.screenShield._dialog?._clock;
if (this._clockModified || !clock)
return;
this._clockModified = true;
this._injectionManager.overrideMethod(Object.getPrototypeOf(clock), '_updateHint',
() => {
return function () {
this._hint.text = 'Hello World!!!';
};
});
clock._updateHint();
}
}
That should cover both the case where the dialog is created before the extension is enabled (explicit lock) and where the extension is enabled first (automatic lock on idle).
It still has the issue pointed out by GdH: If the seatâs touch-mode changes, the original _updateHint() method will run (because it was bound before the extension replaced it).
I tried to understand your above code, it worked for âHello World!!!â text. As I have much planning for tweaking the content on lock screen, my trails were not working. So I have gone with the ModifiedClock.js file.
I would like to learn more from you in the future about what you have mentioned âleakingâ, If I get some more knowledge , I will tweak my extensions in future.
Hello @fmuellner, I tried to refactor the code to work only on unlock-dialog. I am in doubt on disable function and there is a internal disable switch with the prefs.js. I am not sure is that a rite way. In enable.js I am using the condition if (this._dialog && !disable) like below.
But again, whatâs the use case here? There already is a setting to enable or disable extensions, and the enable() and disable() methods are called accordingly. Why make things more complicated by duplicating the whole thing?
Also please try to be more sparse with personal mentions. Answering a question doesnât turn a person into a personal assistant that is responsible for assisting with all future questions.
Hi @fmuellner, I am sorry if I did wrong regarding your last message. I understand what you mean.
regarding disable switch in the preferences is because:
Since its using unlock-dialog session mode only, user cant enable or disable this extension at all.
If user wants to temporarily disable the extension there is no way. Only way is user has to remove the extension.
I tried to use gnome-extensions disable command line, it is working but it too have a bug may be linked to original bug. The bug I noticed is the command line cant work with Tab Completion. means user have to copy paste the uuid of the extension handy while running the command.