diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js')
| -rw-r--r-- | raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js b/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js new file mode 100644 index 0000000..8db37a4 --- /dev/null +++ b/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/dbus-service/shutdown-timer-dbus.js @@ -0,0 +1,72 @@ +// SPDX-FileCopyrightText: 2023 Deminder <tremminder@gmail.com> +// SPDX-License-Identifier: GPL-3.0-or-later + +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; + +import { loadInterfaceXML, logDebug } from '../modules/util.js'; +import { Timer } from './timer.js'; + +export const ShutdownTimerName = 'org.gnome.Shell.Extensions.ShutdownTimer'; +export const ShutdownTimerObjectPath = + '/org/gnome/Shell/Extensions/ShutdownTimer'; +export const ShutdownTimerIface = await loadInterfaceXML(ShutdownTimerName); + +export class ShutdownTimerDBus { + constructor({ settings }) { + this._dbusImpl = Gio.DBusExportedObject.wrapJSObject( + ShutdownTimerIface, + this + ); + this._dbusImpl.export(Gio.DBus.session, ShutdownTimerObjectPath); + + this._timer = new Timer({ settings }); + this._timer.connect('message', (_, msg) => { + logDebug('[shutdown-timer-dbus] msg', msg); + this._dbusImpl.emit_signal('OnMessage', new GLib.Variant('(s)', [msg])); + }); + this._timer.connect('change', () => { + logDebug('[shutdown-timer-dbus] state', this._timer.state); + this._dbusImpl.emit_signal( + 'OnStateChange', + new GLib.Variant('(s)', [this._timer.state]) + ); + }); + this._timer.connect('change-external', () => { + this._dbusImpl.emit_signal('OnExternalChange', null); + }); + } + + async ScheduleShutdownAsync(parameters, invocation) { + const [shutdown, action] = parameters; + logDebug( + '[sdt-dbus] [ScheduleShutdownAsync] shutdown', + shutdown, + 'action', + action + ); + await this._timer.toggleShutdown(shutdown, action); + invocation.return_value(null); + } + + async ScheduleWakeAsync(parameters, invocation) { + const [wake] = parameters; + logDebug('[sdt-dbus] [ScheduleWakeAsync] wake', wake); + await this._timer.toggleWake(wake); + invocation.return_value(null); + } + + GetStateAsync(_, invocation) { + logDebug('[sdt-dbus] [GetStateAsync]'); + invocation.return_value(new GLib.Variant('(s)', [this._timer.state])); + return Promise.resolve(); + } + + destroy() { + logDebug('[sdt-dbus] destroy'); + this._dbusImpl.unexport(); + this._dbusImpl = null; + this._timer.destroy(); + this._timer = null; + } +} |