@dderevjanik/termux-api
Version:
This library allows you to interact with your Android device from Node.js using termux-api
30 lines (27 loc) • 656 B
text/typescript
import { exec } from "child_process";
export interface ClipboardSetOptions {
/**
* Clipboard text to set
*/
text: string;
}
/**
* Set the system clipboard text
*/
export async function clipboardSet(
options: ClipboardSetOptions
): Promise<void> {
return new Promise<void>((resolve, reject) => {
// TODO: Fix escape characters in text ""
const command = `termux-clipboard-set "${options.text}"`;
exec(command, (error, stdout, stderr) => {
if (error) {
return reject(`Error: ${error.message}`);
}
if (stderr) {
return reject(`Error: ${stderr}`);
}
return resolve();
});
});
}