blob: 5913d9c873a897e9e889d07056cc479800e29949 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { EFIBootManager } from "./efibootmgr.js";
import { SystemdBoot } from './systemdBoot.js';
import { Grub } from './grub.js';
export const BootLoaders = {
EFI: "EFI Boot Manager",
GRUB: "Grub",
SYSD: "Systemd Boot",
UNKNOWN: "Unknown Boot Loader"
}
export class Bootloader {
/**
* Gets the first available boot loader type on the current system
* @returns BootLoaders type. Can be "EFI", "SYSD", "GRUB", or "UNKNOWN"
*/
static async GetUseableType(extension) {
const settings = extension.getSettings('org.gnome.shell.extensions.customreboot');
if (await EFIBootManager.IsUseable() && settings.get_boolean('use-efibootmgr')) return BootLoaders.EFI;
if (await Grub.IsUseable() && settings.get_boolean('use-grub')) return BootLoaders.GRUB;
if (await SystemdBoot.IsUseable() && settings.get_boolean('use-systemd-boot')) return BootLoaders.SYSD;
return BootLoaders.UNKNOWN;
}
/**
* Gets a instance of the provided boot loader
* @returns A boot loader if one is found otherwise undefined
*/
static async GetUseable(type) {
if (type === BootLoaders.EFI) return EFIBootManager;
if (type === BootLoaders.SYSD) return SystemdBoot;
if (type === BootLoaders.GRUB) return Grub;
return undefined;
}
}
|