summaryrefslogtreecommitdiffstats
path: root/js/dbusServices/screensaver/screenSaverService.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:54:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:54:43 +0000
commite4283f6d48b98e764b988b43bbc86b9d52e6ec94 (patch)
treec8f7f7a6c2f5faa2942d27cefc6fd46cca492656 /js/dbusServices/screensaver/screenSaverService.js
parentInitial commit. (diff)
downloadgnome-shell-e4283f6d48b98e764b988b43bbc86b9d52e6ec94.tar.xz
gnome-shell-e4283f6d48b98e764b988b43bbc86b9d52e6ec94.zip
Adding upstream version 43.9.upstream/43.9upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/dbusServices/screensaver/screenSaverService.js')
-rw-r--r--js/dbusServices/screensaver/screenSaverService.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/dbusServices/screensaver/screenSaverService.js b/js/dbusServices/screensaver/screenSaverService.js
new file mode 100644
index 0000000..2c1546e
--- /dev/null
+++ b/js/dbusServices/screensaver/screenSaverService.js
@@ -0,0 +1,70 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+/* exported ScreenSaverService */
+
+const { Gio, GLib } = imports.gi;
+
+const { loadInterfaceXML } = imports.misc.dbusUtils;
+const { ServiceImplementation } = imports.dbusService;
+
+const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
+const ScreenSaverProxy = Gio.DBusProxy.makeProxyWrapper(ScreenSaverIface);
+
+var ScreenSaverService = class extends ServiceImplementation {
+ constructor() {
+ super(ScreenSaverIface, '/org/gnome/ScreenSaver');
+
+ this._autoShutdown = false;
+
+ this._proxy = new ScreenSaverProxy(Gio.DBus.session,
+ 'org.gnome.Shell.ScreenShield',
+ '/org/gnome/ScreenSaver',
+ (proxy, error) => {
+ if (error)
+ log(error.message);
+ });
+
+ this._proxy.connectSignal('ActiveChanged',
+ (proxy, sender, params) => {
+ this._dbusImpl.emit_signal('ActiveChanged',
+ new GLib.Variant('(b)', params));
+ });
+ this._proxy.connectSignal('WakeUpScreen',
+ () => this._dbusImpl.emit_signal('WakeUpScreen', null));
+ }
+
+ async LockAsync(params, invocation) {
+ try {
+ await this._proxy.LockAsync(...params);
+ invocation.return_value(null);
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
+ }
+
+ async GetActiveAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveAsync(...params);
+ invocation.return_value(new GLib.Variant('(b)', res));
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
+ }
+
+ async SetActiveAsync(params, invocation) {
+ try {
+ await this._proxy.SetActiveAsync(...params);
+ invocation.return_value(null);
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
+ }
+
+ async GetActiveTimeAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveTimeAsync(...params);
+ invocation.return_value(new GLib.Variant('(u)', res));
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
+ }
+};