From 5d94c0a7d44a2255b81815a52a7056a94a39842d Mon Sep 17 00:00:00 2001 From: nippy Date: Sat, 18 Apr 2026 13:49:56 +0200 Subject: update Raveos themes --- .../installed/customreboot@nova1545/utils.js | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js (limited to 'raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js') diff --git a/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js b/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js new file mode 100644 index 0000000..1c7514a --- /dev/null +++ b/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js @@ -0,0 +1,89 @@ +/* utils.js + * + * Copyright (C) 2020 + * Daniel Shchur (DocQuantum) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later +*/ + +import Gio from "gi://Gio"; + + +var DEBUG = false; + +/** + * @param {String[]} argv + * @param {String} input + * @param {Gio.Cancellable} cancellable + * @returns {Promise} Function execution + * => @returns {[int, String, String]} [StatusCode, STDOUT, STDERR] + * + * Executes a command asynchronously. + */ +export async function ExecCommand(argv, input = null, cancellable = null) { + let flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE; + + if (input !== null) + flags |= Gio.SubprocessFlags.STDIN_PIPE; + + let proc = new Gio.Subprocess({ + argv: argv, + flags: flags + }); + proc.init(cancellable); + return new Promise((resolve,reject) => { + proc.communicate_utf8_async(input, cancellable, (proc, res) => { + try { + resolve([(function() { + if(!proc.get_if_exited()) + throw new Error("Subprocess failed to exit in time!"); + return proc.get_exit_status() + })()].concat(proc.communicate_utf8_finish(res).slice(1))); + } catch (e) { + reject(e); + } + }); + }); +} + +/** + * @param {bool} value + * + * Set's whether to debug or to not. + */ +export function SetDebug(value){ + DEBUG = value; +} + +/** + * @param {string} msg + * + * Logs general messages if debug is set to true. + */ +export function Log(msg) { + if(DEBUG) + console.log(`CustomReboot NOTE: ${msg}`); +} + +/** + * @param {string} msg + * + * Logs warning messages if debug is set to true. + */ +export function LogWarning(msg) { + if(DEBUG) + console.warn(`CustomReboot WARN: ${msg}`); +} \ No newline at end of file -- cgit v1.3