Add tabbed settings and system shell
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { z } from "zod";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export const systemPowerActionSchema = z.enum(["reboot", "poweroff"]);
|
||||
export type SystemPowerAction = z.infer<typeof systemPowerActionSchema>;
|
||||
|
||||
export async function triggerSystemPower(action: SystemPowerAction): Promise<void> {
|
||||
await execFileAsync("/usr/bin/sudo", ["-n", "/usr/local/sbin/pi-car-companion-power", action], {
|
||||
timeout: 10_000,
|
||||
maxBuffer: 16 * 1024
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user