diff options
| author | nippy <you@example.com> | 2026-04-18 13:49:56 +0200 |
|---|---|---|
| committer | nippy <you@example.com> | 2026-04-18 13:49:56 +0200 |
| commit | 5d94c0a7d44a2255b81815a52a7056a94a39842d (patch) | |
| tree | 759bdea9645c6a62f9e1e4c001f7d81cccd120d2 /raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js | |
| parent | e79cdf210b267f21a186255ce1a4d50029439d54 (diff) | |
| download | RaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.tar.gz RaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.zip | |
update Raveos themes
Diffstat (limited to 'raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js')
| -rw-r--r-- | raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js b/raveos-theme/gnome/theme-data/extensions/installed/customreboot@nova1545/efibootmgr.js new file mode 100644 index 0000000..f34cec0 --- /dev/null +++ b/raveos-theme/gnome/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 |