UNPKG

@dderevjanik/termux-api

Version:

This library allows you to interact with your Android device from Node.js using termux-api

25 lines (24 loc) 815 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.brightness = brightness; const child_process_1 = require("child_process"); /** * Set the screen brightness */ async function brightness(options) { if (options.value !== "auto" && (options.value < 0 || options.value > 255)) { throw new Error("Brightness value should be between 0 and 255"); } return new Promise((resolve, reject) => { const command = `termux-brightness ${options.value}`; (0, child_process_1.exec)(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } return resolve(); }); }); }