//@ts-check import { dlopen, FFIType } from 'bun:ffi'; /* Perform a hard reset now. */ const RB_AUTOBOOT = 0x01234567 /* Halt the system. */ const RB_HALT_SYSTEM = 0xcdef0123 /* Enable reboot using Ctrl-Alt-Delete keystroke. */ const RB_ENABLE_CAD = 0x89abcdef /* Disable reboot using Ctrl-Alt-Delete keystroke. */ const RB_DISABLE_CAD = 0 /* Stop system and switch power off if possible. */ const RB_POWER_OFF = 0x4321fedc /* Suspend system using software suspend. */ const RB_SW_SUSPEND = 0xd000fce2 /* Reboot system into new kernel. */ //no idea how to use that but hey const RB_KEXEC = 0x45584543 const { symbols: { reboot, }, } = dlopen('/usr/lib/libc.so.6', { reboot: { args: [ FFIType.int ], returns: FFIType.int, }, }); export function disableCtrlAltSupr() { reboot(RB_DISABLE_CAD) } export function enableCtrlAltSupr() { reboot(RB_ENABLE_CAD) } export function halt() { reboot(RB_HALT_SYSTEM) } export function classicReboot() { reboot(RB_AUTOBOOT) } export function powerOff() { reboot(RB_POWER_OFF) } export function suspend() { reboot(RB_SW_SUSPEND) }