@dderevjanik/termux-api
Version:
This library allows you to interact with your Android device from Node.js using termux-api
21 lines (19 loc) • 509 B
text/typescript
import { exec } from "child_process";
/**
* Get the system clipboard text
*/
export async function clipboardGet(): Promise<string> {
return new Promise<string>((resolve, reject) => {
const command = `termux-clipboard-set`;
exec(command, (error, stdout, stderr) => {
if (error) {
return reject(`Error: ${error.message}`);
}
if (stderr) {
return reject(`Error: ${stderr}`);
}
const output = stdout.trim();
return resolve(output);
});
});
}