56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
//@ts-check
|
|
/* 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
|
|
|
|
/**
|
|
@type {{
|
|
reboot: (rebootid: number) => void //https://unix.superglobalmegacorp.com/Net2/newsrc/sys/syscall.h.html
|
|
syscall: (syscallid: number) => void
|
|
}}
|
|
*///@ts-expect-error
|
|
const syscalls = require('./syscall.node')
|
|
|
|
function disableCtrlAltSupr() {
|
|
syscalls.reboot(RB_DISABLE_CAD)
|
|
}
|
|
|
|
function enableCtrlAltSupr() {
|
|
syscalls.reboot(RB_ENABLE_CAD)
|
|
}
|
|
|
|
function halt() {
|
|
syscalls.reboot(RB_HALT_SYSTEM)
|
|
}
|
|
|
|
function reboot() {
|
|
syscalls.reboot(RB_AUTOBOOT)
|
|
}
|
|
|
|
function powerOff() {
|
|
syscalls.reboot(RB_POWER_OFF)
|
|
}
|
|
|
|
function suspend() {
|
|
syscalls.reboot(RB_SW_SUSPEND)
|
|
}
|
|
|
|
|
|
module.exports = { disableCtrlAltSupr, enableCtrlAltSupr, halt, reboot, powerOff, suspend } |