├── LICENSE
├── Makefile
├── README.md
├── Screenshot.png
└── unblank@sun.wxg@gmail.com
├── extension.js
├── metadata.json
├── prefs.js
└── schemas
├── gschemas.compiled
└── org.gnome.shell.extensions.unblank.gschema.xml
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Xiaoguang Wang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ifeq ($(strip $(DESTDIR)),)
2 | INSTALL_TYPE=local
3 | INSTALLBASE=$(HOME)/.local/share/gnome-shell/extensions
4 | else
5 | INSTALL_TYPE=system
6 | SHARE_PREFIX=$(DESTDIR)/usr/share
7 | INSTALLBASE=$(SHARE_PREFIX)/gnome-shell/extensions
8 | endif
9 | INSTALLNAME=unblank@sun.wxg@gmail.com
10 | GSCHEMA_FILE=org.gnome.shell.extensions.unblank.gschema.xml
11 |
12 | schemas:
13 | glib-compile-schemas $(INSTALLNAME)/schemas/
14 | submit: schemas
15 | cd $(INSTALLNAME)/ && zip -r ~/unblank.zip *
16 |
17 | install:
18 | rm -rf $(INSTALLBASE)/$(INSTALLNAME) $(SHARE_PREFIX)/glib-2.0/schemas/$(GSCHEMA_FILE)
19 | mkdir -p $(INSTALLBASE)/$(INSTALLNAME)
20 | cp -r $(INSTALLNAME)/* $(INSTALLBASE)/$(INSTALLNAME)/
21 | ifeq ($(INSTALL_TYPE),system)
22 | mkdir -p $(SHARE_PREFIX)/glib-2.0/schemas
23 | cp -r $(INSTALLBASE)/$(INSTALLNAME)/schemas/$(GSCHEMA_FILE) $(SHARE_PREFIX)/glib-2.0/schemas
24 | rm -rf $(INSTALLBASE)/$(INSTALLNAME)/schemas
25 | endif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gnome-shell-extension-unblank
2 |
3 | Unblank screen when screen saver becomes active.
4 |
5 | After you install extension, the extension will become enable. If you want to disable extension, you need to delete this extension or go to this extension settings to turn off switch.
6 |
7 | ## Install
8 |
9 | ```
10 | make install
11 | ```
12 | restart system
13 |
14 | ### From gnome extensions website
15 |
16 | https://extensions.gnome.org/extension/1414/unblank/
17 |
18 | 
19 |
--------------------------------------------------------------------------------
/Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunwxg/gnome-shell-extension-unblank/1e0ebdcf1fd437d5009f3dc9daf93341cea13a7f/Screenshot.png
--------------------------------------------------------------------------------
/unblank@sun.wxg@gmail.com/extension.js:
--------------------------------------------------------------------------------
1 | // -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
2 | //
3 | import Clutter from 'gi://Clutter';
4 | import Gio from 'gi://Gio';
5 | import GLib from 'gi://GLib';
6 | import Gdk from 'gi://Gdk';
7 | import St from 'gi://St';
8 | import UPower from 'gi://UPowerGlib';
9 |
10 | import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
11 |
12 | import * as Main from 'resource:///org/gnome/shell/ui/main.js';
13 | import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
14 | import * as Overview from 'resource:///org/gnome/shell/ui/overview.js';
15 | import { loadInterfaceXML } from 'resource:///org/gnome/shell/misc/fileUtils.js';
16 |
17 |
18 | const MANUAL_FADE_TIME = 0.3;
19 | const STANDARD_FADE_TIME = 10;
20 |
21 | const UPOWER_BUS_NAME = 'org.freedesktop.UPower';
22 | const UPOWER_OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice';
23 | const DisplayDeviceInterface = loadInterfaceXML('org.freedesktop.UPower.Device');
24 | const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(DisplayDeviceInterface);
25 |
26 | const UPowerIface = loadInterfaceXML('org.freedesktop.UPower');
27 | const UPowerProxy = Gio.DBusProxy.makeProxyWrapper(UPowerIface);
28 |
29 | const BUS_NAME = 'org.gnome.Mutter.DisplayConfig';
30 | const OBJECT_PATH = '/org/gnome/Mutter/DisplayConfig';
31 |
32 | const DisplayConfigIface = ' \
33 | \
34 | \
35 | \
36 | ';
37 |
38 | const DisplayConfigProxy = Gio.DBusProxy.makeProxyWrapper(DisplayConfigIface);
39 |
40 | class Unblank {
41 | constructor(settings) {
42 | this.gsettings = settings;
43 | this.proxy = new DisplayConfigProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH, () => {});
44 |
45 | this.setActiveOrigin = Main.screenShield._setActive;
46 | this.activateFadeOrigin = Main.screenShield._activateFade;
47 | this.resetLockScreenOrigin = Main.screenShield._resetLockScreen;
48 | this.onUserBecameActiveOrigin = Main.screenShield._onUserBecameActive;
49 |
50 | this._pointerMoved = false;
51 | this.hideLightboxId = 0;
52 | this._turnOffMonitorId = 0;
53 | this.inLock = false;
54 | this._activeOnce = false;
55 | this.enabled = false;
56 |
57 | //this.powerProxy = new PowerManagerProxy(Gio.DBus.system, UPOWER_BUS_NAME, UPOWER_OBJECT_PATH,
58 | this.powerProxy = new UPowerProxy(Gio.DBus.system,
59 | 'org.freedesktop.UPower',
60 | '/org/freedesktop/UPower',
61 | (proxy, error) => {
62 | if (error) {
63 | log(error.message);
64 | return;
65 | }
66 | this.powerProxy.connect('g-properties-changed',
67 | this._onPowerChanged.bind(this));
68 | this._onPowerChanged(); });
69 | }
70 |
71 | enable() {
72 | Main.screenShield._setActive = _setActive;
73 | Main.screenShield._activateFade = _activateFade;
74 | Main.screenShield._resetLockScreen = _resetLockScreen;
75 | Main.screenShield._onUserBecameActive = _onUserBecameActive;
76 | this.enabled = true;
77 | }
78 |
79 | disable() {
80 | Main.screenShield._setActive = this.setActiveOrigin;
81 | Main.screenShield._activateFade = this.activateFadeOrigin;
82 | Main.screenShield._resetLockScreen = this.resetLockScreenOrigin;
83 | Main.screenShield._onUserBecameActive = this.onUserBecameActiveOrigin;
84 | this.enabled = false;
85 | }
86 |
87 | isUnblank() {
88 | this.isOnBattery = (this.gsettings.get_boolean('power') && this.powerProxy.OnBattery);
89 | return !this.isOnBattery;
90 | }
91 |
92 | _onPowerChanged() {
93 | this.isOnBattery = (this.gsettings.get_boolean('power') && this.powerProxy.OnBattery);
94 |
95 | if (Main.screenShield._isActive) {
96 | if (this.isOnBattery) {
97 | Main.screenShield.emit('active-changed');
98 | Main.screenShield.activate(false);
99 | this._activeOnce = true;
100 | //_turnOffMonitor();
101 | } else
102 | _turnOnMonitor();
103 | }
104 | }
105 | }
106 |
107 | function _setActive(active) {
108 | let prevIsActive = this._isActive;
109 | this._isActive = active;
110 | unblank.inLock = active;
111 |
112 | if (prevIsActive != this._isActive) {
113 | if (!unblank.isUnblank() || unblank._activeOnce) {
114 | this.emit('active-changed');
115 | unblank._activeOnce = false;
116 | }
117 | }
118 | if (active) {
119 | _activateTimer();
120 | } else {
121 | _deactiveTimer();
122 | }
123 |
124 | if (this._loginSession)
125 | this._loginSession.SetLockedHintRemote(active);
126 |
127 | this._syncInhibitor();
128 | }
129 |
130 | function _activateFade(lightbox, time) {
131 | if (unblank.inLock) {
132 | _activateTimer();
133 | return;
134 | }
135 |
136 | Main.uiGroup.set_child_above_sibling(lightbox, null);
137 | if (unblank.isUnblank() && !this._isActive) {
138 | lightbox.lightOn(time);
139 | unblank.hideLightboxId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, time + 1000,
140 | () => { lightbox.lightOff();
141 | _activateTimer();
142 | unblank.hideLightboxId = 0;
143 | return GLib.SOURCE_REMOVE; });
144 | } else {
145 | lightbox.lightOn(time);
146 | }
147 |
148 | if (this._becameActiveId == 0)
149 | this._becameActiveId = this.idleMonitor.add_user_active_watch(this._onUserBecameActive.bind(this))
150 | }
151 |
152 | function _onUserBecameActive() {
153 | if (this._becameActiveId != 0) {
154 | this.idleMonitor.remove_watch(this._becameActiveId);
155 | this._becameActiveId = 0;
156 | }
157 |
158 | if (unblank.hideLightboxId != 0) {
159 | GLib.source_remove(unblank.hideLightboxId);
160 | unblank.hideLightboxId= 0;
161 | }
162 | //_deactiveTimer();
163 | //_turnOnMonitor();
164 |
165 | if (this._isActive || this._isLocked) {
166 | this._longLightbox.lightOff();
167 | this._shortLightbox.lightOff();
168 | } else {
169 | this.deactivate(false);
170 | }
171 | }
172 |
173 | function _resetLockScreen(params) {
174 | _activateTimer();
175 | if (this._lockScreenState != MessageTray.State.HIDDEN)
176 | return;
177 |
178 | this._lockScreenGroup.show();
179 | this._lockScreenState = MessageTray.State.SHOWING;
180 |
181 | let fadeToBlack;
182 | if (unblank.isUnblank()) {
183 | fadeToBlack = false;
184 | } else {
185 | fadeToBlack = params.fadeToBlack;
186 | }
187 |
188 | if (params.animateLockScreen) {
189 | this._lockDialogGroup.translation_y = -global.screen_height;
190 | this._lockDialogGroup.remove_all_transitions();
191 | this._lockDialogGroup.ease({
192 | translation_y: 0,
193 | duration: Overview.ANIMATION_TIME,
194 | mode: Clutter.AnimationMode.EASE_OUT_QUAD,
195 | onComplete: () => {
196 | this._lockScreenShown({ fadeToBlack, animateFade: true });
197 | },
198 | });
199 | } else {
200 | this._lockDialogGroup.translation_y = 0;
201 | this._lockScreenShown({ fadeToBlack, animateFade: false });
202 | }
203 |
204 | this._dialog.grab_key_focus();
205 | }
206 |
207 | function _changeToBlank() {
208 | if (!unblank._activeOnce) {
209 | Main.screenShield.emit('active-changed');
210 | unblank._activeOnce = true;
211 | }
212 | }
213 |
214 | function _activateTimer() {
215 | _deactiveTimer();
216 | let timer = unblank.gsettings.get_int('time');
217 | if (timer != 0) {
218 | unblank._turnOffMonitorId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, timer, () => {
219 | _changeToBlank();
220 | //_turnOffMonitor();
221 | unblank._turnOffMonitorId = 0;
222 | return GLib.SOURCE_REMOVE;
223 | });
224 | GLib.Source.set_name_by_id(unblank._turnOffMonitorId, '[gnome-shell] this._turnOffMonitor');
225 | }
226 | }
227 |
228 | function _deactiveTimer() {
229 | if (unblank._turnOffMonitorId != 0) {
230 | GLib.source_remove(unblank._turnOffMonitorId);
231 | unblank._turnOffMonitorId = 0;
232 | }
233 | }
234 |
235 | function _turnOnMonitor() {
236 | unblank.proxy.PowerSaveMode = 0;
237 | }
238 |
239 | function _turnOffMonitor() {
240 | unblank.proxy.PowerSaveMode = 1;
241 | }
242 |
243 | var unblank = null;
244 | var enabled = false;
245 |
246 | export default class PanelScrollExtension extends Extension {
247 | constructor(metadata) {
248 | super(metadata);
249 | }
250 |
251 | enable() {
252 | this._settings = this.getSettings();
253 |
254 | if (enabled)
255 | return;
256 | unblank = new Unblank(this._settings);
257 | unblank.enable();
258 | enabled = true;
259 |
260 | }
261 |
262 | disable() {
263 | if (!Main.sessionMode.isLocked) {
264 | unblank.disable();
265 | unblank = null
266 | enabled = false;
267 | this._settings = null;
268 | }
269 | }
270 | }
271 |
--------------------------------------------------------------------------------
/unblank@sun.wxg@gmail.com/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "uuid": "unblank@sun.wxg@gmail.com",
3 | "extension-id": "unblank",
4 | "settings-schema": "org.gnome.shell.extensions.unblank",
5 | "gettext-domain": "gnome-shell-extensions",
6 | "name": "Unblank lock screen",
7 | "description": "Unblank lock screen.",
8 | "shell-version": [
9 | "45",
10 | "46",
11 | "47",
12 | "48",
13 | "49"
14 | ],
15 | "original-authors": "sun.wxg@gmail.com",
16 | "url": "https://github.com/sunwxg/gnome-shell-extension-unblank"
17 | }
18 |
--------------------------------------------------------------------------------
/unblank@sun.wxg@gmail.com/prefs.js:
--------------------------------------------------------------------------------
1 | import Gtk from 'gi://Gtk';
2 |
3 | import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
4 |
5 | const SCHEMA_NAME = 'org.gnome.shell.extensions.unblank';
6 |
7 | function buildPrefsWidget(gsettings) {
8 | let widget = new Gtk.Box({
9 | orientation: Gtk.Orientation.VERTICAL,
10 | margin_top: 10,
11 | margin_bottom: 10,
12 | margin_start: 10,
13 | margin_end: 10,
14 | });
15 |
16 | let vbox = new Gtk.Box({
17 | orientation: Gtk.Orientation.VERTICAL,
18 | margin_top: 10
19 | });
20 | vbox.set_size_request(550, 350);
21 |
22 | let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, margin_top: 5 });
23 | let power_setting_label = new Gtk.Label({ label: "Only unblank when on AC",
24 | hexpand: true,
25 | xalign: 0 });
26 | let power_setting_switch = new Gtk.Switch({ active: gsettings.get_boolean('power') });
27 |
28 | power_setting_switch.connect('notify::active',
29 | function (button) { gsettings.set_boolean('power', button.active); });
30 |
31 | hbox.append(power_setting_label);
32 | hbox.append(power_setting_switch);
33 | vbox.append(hbox);
34 |
35 | hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, margin_top: 5 });
36 | let timebox_label = new Gtk.Label({ label: "Timeout to blank after locking the screen",
37 | hexpand: true,
38 | xalign: 0 });
39 | let timebox_comboBox= new Gtk.ComboBoxText();
40 | timebox_comboBox.connect('changed',
41 | (box) => { gsettings.set_int('time', Number(box.get_active_id())) });
42 |
43 | timebox_comboBox.append("0", "Never");
44 | timebox_comboBox.append("300", "5 minutes");
45 | timebox_comboBox.append("600", "10 minutes");
46 | timebox_comboBox.append("900", "15 minutes");
47 | timebox_comboBox.append("1800", "30 minutes");
48 | timebox_comboBox.append("3600", "60 minutes");
49 | timebox_comboBox.append("5400", "90 minutes");
50 | timebox_comboBox.append("7200", "120 minutes");
51 |
52 | timebox_comboBox.set_active_id(gsettings.get_int('time').toString());
53 |
54 | hbox.append(timebox_label);
55 | hbox.append(timebox_comboBox);
56 | vbox.append(hbox);
57 |
58 | widget.append(vbox);
59 |
60 | return widget;
61 | }
62 |
63 | function addBoldTextToBox(text, box) {
64 | let txt = new Gtk.Label({xalign: 0});
65 | txt.set_markup('' + text + '');
66 | txt.set_line_wrap(true);
67 | box.append(txt);
68 | }
69 |
70 | export default class UnblankPrefs extends ExtensionPreferences {
71 | getPreferencesWidget() {
72 | return buildPrefsWidget(this.getSettings());
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/unblank@sun.wxg@gmail.com/schemas/gschemas.compiled:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunwxg/gnome-shell-extension-unblank/1e0ebdcf1fd437d5009f3dc9daf93341cea13a7f/unblank@sun.wxg@gmail.com/schemas/gschemas.compiled
--------------------------------------------------------------------------------
/unblank@sun.wxg@gmail.com/schemas/org.gnome.shell.extensions.unblank.gschema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | Key to switch unblank
6 |
7 |
8 |
9 |
10 | 0
11 | Time to close monitor
12 |
13 |
14 |
15 |
16 | true
17 | Key to switch on power only
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------