gnome-shell-extension-unblank
gnome-shell-extension-unblank copied to clipboard
Feature request: Add option to only unblank on lock shortcut (Super+L etc), NOT on timeout/screensaver
I implemented this from another extension [email protected]
here:
const ScreenShield = imports.ui.screenShield;
const Main = imports.ui.main;
const Me = imports.misc.extensionUtils.getCurrentExtension();
let extensionActive = false;
let orig_activateFade = ScreenShield.ScreenShield.prototype._activateFade;
let orig_completeLockScreenShown = ScreenShield.ScreenShield.prototype._completeLockScreenShown;
// don't fade in a full screen black box which would obscure the view
function noFade_activateFade (lightbox, time) {
if (!Me.keyboardSource)
orig_activateFade.call(this, lightbox, time);
Me.keyboardSource = false;
};
// basically a copy of the original method without the emission of the
// "active-changed" signal which would cause gnome-settings-daemon to
// blank the screen
function noFade_completeLockScreenShown () {
if (!Me.keyboardSource) return orig_completeLockScreenShown.call(this);
this._isActive = true;
if (this._aboutToSuspend)
this._uninhibitSuspend();
Main.screenShield.emit('lock-screen-shown');
}
function init() {
}
function enable() {
if (!extensionActive) {
extensionActive = true;
Me.keyboardSource = false;
ScreenShield.ScreenShield.prototype._activateFade = noFade_activateFade;
ScreenShield.ScreenShield.prototype._completeLockScreenShown = noFade_completeLockScreenShown;
let [res, out] = imports.gi.GLib.spawn_command_line_sync("gsettings get org.gnome.settings-daemon.plugins.media-keys screensaver");
let strout = imports.byteArray.toString(out).replace(/'/g,'"')
let lockKeys = JSON.parse(strout);
let action = global.display.grab_accelerator(lockKeys[0], imports.gi.Meta.KeyBindingFlags.NONE);
let name = imports.gi.Meta.external_binding_name_for_action(action)
Main.wm.allowKeybinding(name, imports.gi.Shell.ActionMode.ALL);
this.lockActionKey = action;
global.display.connect('accelerator-activated', (display, actionId, deviceId, timestamp) => {
if (actionId == action) {
Me.keyboardSource = true;
Main.screenShield.lock(true);
}
});
}
}
function disable() {
// Only allow disabling the extension when in 'user' mode (i.e. manually),
// but not in lock-screen mode.
if (extensionActive && Main.sessionMode.currentMode == 'user') {
extensionActive = false;
ScreenShield.ScreenShield.prototype._activateFade = orig_activateFade;
ScreenShield.ScreenShield.prototype._completeLockScreenShown = orig_completeLockScreenShown;
}
}
I attempted to with unblank but seeing as it has a lot more function overrides I ran into a problem that it seems some signal wasn't emitting and the lock screen doesn't redisplay on user action, just the block out. Here is what I tried: Unblank.zip