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 --- .../installed/customreboot@nova1545/efibootmgr.js | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 raveos-gnome-theme/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js (limited to 'raveos-gnome-theme/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js') diff --git a/raveos-gnome-theme/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js b/raveos-gnome-theme/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js new file mode 100644 index 0000000..f34cec0 --- /dev/null +++ b/raveos-gnome-theme/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js @@ -0,0 +1,101 @@ +import Gio from "gi://Gio"; +import { ExecCommand, Log, LogWarning } from './utils.js'; + +/** + * Represents efibootmgr + */ +export class EFIBootManager { + /** + * Get's all available boot options + * @returns {[Map, string]} Map(title, id), defaultOption + */ + static async GetBootOptions() { + const [status, stdout, stderr] = await ExecCommand(['efibootmgr'],); + const lines = stdout.split("\n"); + + let boot_first = "0000"; + + const boot_options = new Map(); + + for (let l = 0; l < lines.length; l++) { + const line = lines[l]; + if (line.startsWith("BootOrder:")) { + boot_first = line.split(" ")[1].split(",")[0]; + continue; + } + + const regex = /(Boot[0-9]{4})/; + const vLine = regex.exec(line) + if (vLine && vLine.length) { + const option = line.replace("Boot", "").split("*"); + const title = option[1]; + if (title.includes("HD") || title.includes("RC")) { + const trimed_title = title.replace(/(?<=[\S\s]*)(HD|RC)([\s\S()]*|$)/, "").trim(); + boot_options.set(trimed_title, option[0].trim()); + } + else { + boot_options.set(option[1].trim(), option[0].trim()); + } + } + } + + return [boot_options, boot_first]; + } + + /** + * Set's the next boot option + * @param {string} id + * @returns True if the boot option was set, otherwise false + */ + static async SetBootOption(id) { + if (!this.IsUseable()) return false; + const [status, stdout, stderr] = await ExecCommand(['/usr/bin/pkexec', 'efibootmgr', '-n', id],); + if (status === 0) { + Log(`Set boot option to ${id}`); + return true; + } + LogWarning("Unable to set boot option using efibootmgr"); + return false; + } + + /** + * Can we use this bootloader? + * @returns True if useable otherwise false + */ + static async IsUseable() { + return await this.GetBinary() !== ""; + } + + /** + * Get's efibootmgr binary path + * @returns A string containing the location of the binary, if none is found returns a blank string + */ + static async GetBinary() { + let paths = ["/usr/bin/efibootmgr", "/usr/sbin/efibootmgr"]; + + let file; + + for (let i = 0; i < paths.length; i++) { + file = Gio.file_new_for_path(paths[i]); + if (file.query_exists(null)) { + return paths[i]; + } + } + + return ""; + } + + /** + * This boot loader cannot be quick rebooted + */ + static async CanQuickReboot() { + return false; + } + + /** + * This boot loader cannot be quick rebooted + */ + static async QuickRebootEnabled() { + return false; + } +} \ No newline at end of file -- cgit v1.3