import { exec } from "child_process"; export interface VibrateOptions { /** * The duration to vibrate in ms * @default 1000 */ duration?: number; /** * Force vibration even in silent mode * @default false */ force?: boolean; } /** * Vibrate the device */ export async function vibrate(options: VibrateOptions = {}): Promise { const opts: VibrateOptions = { duration: 1_000, // number: "", ...options, }; return new Promise((resolve, reject) => { const command = `termux-vibrate -d ${opts.duration} ${ opts.force ? "-f" : "" }`; exec(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } return resolve(); }); }); }