summaryrefslogtreecommitdiff
path: root/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js
diff options
context:
space:
mode:
authornippy <you@example.com>2026-04-18 13:49:56 +0200
committernippy <you@example.com>2026-04-18 13:49:56 +0200
commit5d94c0a7d44a2255b81815a52a7056a94a39842d (patch)
tree759bdea9645c6a62f9e1e4c001f7d81cccd120d2 /raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js
parente79cdf210b267f21a186255ce1a4d50029439d54 (diff)
downloadRaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.tar.gz
RaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.zip
update Raveos themes
Diffstat (limited to 'raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js')
-rw-r--r--raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/utils.js89
1 files changed, 89 insertions, 0 deletions
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) <shchurgood@gmail.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * 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