summaryrefslogtreecommitdiff
path: root/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers
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/Vitals@CoreCoding.com/helpers
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/Vitals@CoreCoding.com/helpers')
-rw-r--r--raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js82
-rw-r--r--raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js54
2 files changed, 136 insertions, 0 deletions
diff --git a/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js b/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js
new file mode 100644
index 0000000..a7211b9
--- /dev/null
+++ b/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js
@@ -0,0 +1,82 @@
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib'
+
+// convert Uint8Array into a literal string
+function convertUint8ArrayToString(contents) {
+ const decoder = new TextDecoder('utf-8');
+ return decoder.decode(contents).trim();
+}
+
+export function File(path) {
+ if (path.indexOf('https://') == -1)
+ this.file = Gio.File.new_for_path(path);
+ else
+ this.file = Gio.File.new_for_uri(path);
+}
+
+File.prototype.read = function(delimiter = '', strip_header = false) {
+ return new Promise((resolve, reject) => {
+ try {
+ this.file.load_contents_async(null, function(file, res) {
+ try {
+ // grab contents of file or website
+ let contents = file.load_contents_finish(res)[1];
+
+ // convert contents to string
+ contents = convertUint8ArrayToString(contents);
+
+ // split contents by delimiter if passed in
+ if (delimiter) contents = contents.split(delimiter);
+
+ // optionally strip header when converting to a list
+ if (strip_header) contents.shift();
+
+ // return results
+ resolve(contents);
+ } catch (e) {
+ reject(e.message);
+ }
+ });
+ } catch (e) {
+ reject(e.message);
+ }
+ });
+};
+
+File.prototype.list = function() {
+ return new Promise((resolve, reject) => {
+ let max_items = 125, results = [];
+
+ try {
+ this.file.enumerate_children_async(Gio.FILE_ATTRIBUTE_STANDARD_NAME, Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_LOW, null, function(file, res) {
+ try {
+ let enumerator = file.enumerate_children_finish(res);
+
+ let callback = function(enumerator, res) {
+ try {
+ let files = enumerator.next_files_finish(res);
+ for (let i = 0; i < files.length; i++) {
+ results.push(files[i].get_attribute_as_string(Gio.FILE_ATTRIBUTE_STANDARD_NAME));
+ }
+
+ if (files.length == 0) {
+ enumerator.close_async(GLib.PRIORITY_LOW, null, function(){});
+ resolve(results);
+ } else {
+ enumerator.next_files_async(max_items, GLib.PRIORITY_LOW, null, callback);
+ }
+ } catch (e) {
+ reject(e.message);
+ }
+ };
+
+ enumerator.next_files_async(max_items, GLib.PRIORITY_LOW, null, callback);
+ } catch (e) {
+ reject(e.message);
+ }
+ });
+ } catch (e) {
+ reject(e.message);
+ }
+ });
+};
diff --git a/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js b/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js
new file mode 100644
index 0000000..df0bf49
--- /dev/null
+++ b/raveos-gnome-theme/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js
@@ -0,0 +1,54 @@
+import GLib from 'gi://GLib';
+import Gio from 'gi://Gio';
+
+// convert Uint8Array into a literal string
+function convertUint8ArrayToString(contents) {
+ const decoder = new TextDecoder('utf-8');
+ return decoder.decode(contents).trim();
+}
+
+export function SubProcess(command) {
+ this.sub_process = Gio.Subprocess.new(command, Gio.SubprocessFlags.STDOUT_PIPE);
+ this.stdout = this.sub_process.get_stdout_pipe();
+}
+
+SubProcess.prototype.read = function(delimiter = '') {
+ return new Promise((resolve, reject) => {
+ this.stdout.read_bytes_async(512, GLib.PRIORITY_LOW, null, function(stdout, res) {
+ try {
+ let read_bytes = stdout.read_bytes_finish(res).get_data();
+
+ // convert contents to string
+ let read_str = convertUint8ArrayToString(read_bytes);
+
+ // split read_str by delimiter if passed in
+ if (delimiter) {
+ if (read_str == '')
+ read_str = []; // EOF, ''.split(delimiter) would return ['']
+ else
+ read_str = read_str.split(delimiter);
+ }
+
+ // return results
+ resolve(read_str);
+ } catch (e) {
+ if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.PENDING)) {
+ // previous read attempt is still waiting for something from stdout
+ // ignore second attempt, return empty data (like EOF)
+ if (delimiter) resolve([]);
+ else resolve('');
+ } else {
+ reject(e.message);
+ }
+ }
+ });
+ });
+};
+
+SubProcess.prototype.terminate = function() {
+ const SIGINT = 2;
+ this.sub_process.send_signal(SIGINT);
+ this.sub_process = null;
+ this.stdout.close_async(GLib.PRIORITY_LOW, null, null);
+ this.stdout = null;
+};