summaryrefslogtreecommitdiff
path: root/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js
diff options
context:
space:
mode:
authorAlexanderCurl <alexc@alexc.hu>2026-04-18 17:46:06 +0100
committerAlexanderCurl <alexc@alexc.hu>2026-04-18 17:46:06 +0100
commit70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch)
treeab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js
parent5d94c0a7d44a2255b81815a52a7056a94a39842d (diff)
downloadRaveOS-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/modules/install.js')
-rw-r--r--raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js b/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js
new file mode 100644
index 0000000..701da6a
--- /dev/null
+++ b/raveos-gnome-theme/theme-data/extensions/installed/ShutdownTimer@deminder/modules/install.js
@@ -0,0 +1,64 @@
+// SPDX-FileCopyrightText: 2023 Deminder <tremminder@gmail.com>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import GLib from 'gi://GLib';
+import Gio from 'gi://Gio';
+import { gettext as _ } from './translation.js';
+
+import { execCheck, installedScriptPath } from '../dbus-service/control.js';
+import { logDebug } from './util.js';
+
+export class Install {
+ destroy() {
+ if (this.installCancel !== undefined) {
+ this.installCancel.cancel();
+ }
+ this.installCancel = undefined;
+ }
+
+ /**
+ * @param installerScriptPath
+ * @param action
+ * @param logInstall
+ */
+ async installAction(installerScriptPath, action, logInstall) {
+ const label = this.actionLabel(action);
+ if (this.installCancel !== undefined) {
+ logDebug(`Trigger cancel install. ${label}`);
+ this.installCancel.cancel();
+ } else {
+ logDebug(`Trigger ${action} action.`);
+ this.installCancel = new Gio.Cancellable();
+ logInstall(`[${_('START')} ${label}]`);
+ try {
+ const user = GLib.get_user_name();
+ logDebug(`? installer.sh --tool-user ${user} ${action}`);
+ await execCheck(
+ ['pkexec', installerScriptPath, '--tool-user', user, action],
+ this.installCancel,
+ false,
+ logInstall
+ );
+ logInstall(`[${_('END')} ${label}]`);
+ } catch (err) {
+ logInstall(`[${_('FAIL')} ${label}]\n# ${err}`);
+ console.error(err, 'InstallError');
+ } finally {
+ this.installCancel = undefined;
+ }
+ }
+ }
+
+ checkInstalled() {
+ const scriptPath = installedScriptPath();
+ const isScriptInstalled = scriptPath !== null;
+ if (isScriptInstalled) {
+ logDebug(`Existing installation at: ${scriptPath}`);
+ }
+ return isScriptInstalled;
+ }
+
+ actionLabel(action) {
+ return { install: _('install'), uninstall: _('uninstall') }[action];
+ }
+}