From 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 Mon Sep 17 00:00:00 2001 From: AlexanderCurl Date: Sat, 18 Apr 2026 17:46:06 +0100 Subject: Replaced file structures for themes in the correct format --- .../Vitals@CoreCoding.com/helpers/file.js | 82 ---------------------- .../Vitals@CoreCoding.com/helpers/subprocess.js | 54 -------------- 2 files changed, 136 deletions(-) delete mode 100644 raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js delete mode 100644 raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js (limited to 'raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers') diff --git a/raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js b/raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js deleted file mode 100644 index a7211b9..0000000 --- a/raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/file.js +++ /dev/null @@ -1,82 +0,0 @@ -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-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js b/raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js deleted file mode 100644 index df0bf49..0000000 --- a/raveos-theme/gnome/theme-data/extensions/installed/Vitals@CoreCoding.com/helpers/subprocess.js +++ /dev/null @@ -1,54 +0,0 @@ -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; -}; -- cgit v1.3