mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-16 08:14:03 -04:00
* powermenu: derive shortcuts and extra actions from one source The power menu matched keys with a switch that repeated the key hints getPowerActionData already returns, plus a second key list for release. Look the pressed key up against the hints of the visible actions instead, so every action with a hint gets its shortcut and the two cannot drift. Side effects: - Ctrl+letter no longer triggers actions. Only Ctrl+P was excluded before, so Ctrl+R still rebooted. Ctrl combinations are navigation. - U now triggers switch user when it is shown. Its hint already said U. - Releasing a letter with no visible action no longer cancels a hold. SessionService now owns the custom:N action ids as customPowerActions and extraPowerActions, which the power menu and the launcher both use. Actions resolve by index into that list instead of slicing the prefix. * powermenu: add actions that reboot into a chosen efi boot entry Settings → Power & Sleep gets a "Reboot to another OS" card that lists the firmware's active EFI entries through efibootmgr. Each saved entry becomes a "Reboot to <name>" action in the power menu and the launcher, bound to 1-9 in the order it was added. Picking one lists the entries again, and stops with a toast if the id no longer carries the saved label. Otherwise it sets BootNext through pkexec and reboots through SessionService, so custom reboot commands still apply. BootEntryService reports why entries are unavailable: not booted in UEFI mode, efibootmgr missing, or efibootmgr failing with its stderr. Saved entries stay listed in settings whatever the status, so a synced config on another machine can still remove them. efibootmgr parsing and the picker's filtering live in BootEntries.js, covered by tests/boot-entries.test.mjs. * powermenu: ignore special keys in action shortcuts
51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import vm from "node:vm";
|
|
import test from "node:test";
|
|
|
|
const bootEntries = vm.createContext({});
|
|
vm.runInContext(readFileSync(new URL("../Services/BootEntries.js", import.meta.url), "utf8").replace(/^\.pragma.*$/m, ""), bootEntries);
|
|
const plain = value => JSON.parse(JSON.stringify(value));
|
|
|
|
test("parses active entries and the current boot from efibootmgr output", () => {
|
|
// efibootmgr 18 prints the device path after a tab, older releases print only the label
|
|
const output = [
|
|
"BootCurrent: 0001",
|
|
"Timeout: 1 seconds",
|
|
"BootOrder: 0001,0000,0010",
|
|
"Boot0000* Windows Boot Manager\tHD(1,GPT,c28482eb,0x1000,0x830000)/\\EFI\\MICROSOFT\\BOOT\\BOOTMGFW.EFI",
|
|
"Boot0001* Limine\tHD(1,GPT,c28482eb,0x1000,0x830000)/\\EFI\\LIMINE\\LIMINE_X64.EFI",
|
|
"Boot0010 UEFI OS\tHD(1,GPT,c28482eb,0x1000,0x830000)/\\EFI\\BOOT\\BOOTX64.EFI",
|
|
"Boot001a* Fedora",
|
|
""
|
|
].join("\n");
|
|
|
|
const parsed = bootEntries.parseEntries(output);
|
|
|
|
assert.equal(parsed.currentId, "0001");
|
|
assert.deepEqual(plain(parsed.entries), [
|
|
{ id: "0000", label: "Windows Boot Manager" },
|
|
{ id: "0001", label: "Limine" },
|
|
{ id: "001A", label: "Fedora" }
|
|
]);
|
|
});
|
|
|
|
test("picker skips the running and saved entries and tells duplicate labels apart", () => {
|
|
const entries = [
|
|
{ id: "0000", label: "Windows Boot Manager" },
|
|
{ id: "0001", label: "Limine" },
|
|
{ id: "0002", label: "Fedora" },
|
|
{ id: "0003", label: "Fedora" },
|
|
{ id: "0004", label: "Arch" },
|
|
{ id: "0005", label: "Arch" }
|
|
];
|
|
const saved = [{ id: "0000", label: "Windows Boot Manager" }, { id: "0004", label: "Arch" }];
|
|
|
|
assert.deepEqual(plain(bootEntries.pickerOptions(entries, "0001", saved)), [
|
|
{ id: "0002", label: "Fedora", name: "Fedora (0002)" },
|
|
{ id: "0003", label: "Fedora", name: "Fedora (0003)" },
|
|
// Its twin is already saved, so the label alone is unambiguous in the picker
|
|
{ id: "0005", label: "Arch", name: "Arch" }
|
|
]);
|
|
});
|