Giter Site home page Giter Site logo

termux's Introduction

termux

NPM Version Dependency Status JavaScript Style Guide

Comprehensive Node.js module for Termux-API

Install

  1. Make sure you've first installed the termux-api on your Android device from the Play store.

  2. Then install the scripts with apt install termux-api.

  3. Finally get this node module:

    $ npm install --save termux

Example usage

const api = require('termux')

if (!api.hasTermux) process.exit(1)

api.vibrate()
   .duration(1000)
   .run()

api.clipboardGet()
   .run()
   .then(function (text) {
     // ...
   })

Available methods

Every command instance has the .run() method that must be used to execute the command. It always return a Promise (eventually with results).

Method Description Parameters
.toast() Show a toast message
set the text to show .text(<str>)
show the toast for a short while .transient()
.vibrate() Vibrate your phone
set the duration in milliseconds .duration(<ms>)
force vibration even in silent mode .force()
.batteryStatus() Get the status of the device battery
.cameraInfo() Get info about device camera(s)
.cameraPhoto() Take a photo and save it to a file (JPEG format)
select the camera by ID .camera(<id>)
output photo file (NB. use an absolute path!) .outputFile(<str>)
.clipboardGet() Get the system clipboard text
.clipboardSet() Set the system clipboard text
text to copy in clipboard .text(<str>)
.contactList() Set the system clipboard text
.contactList() List all contacts
.dialog() Show a text entry dialog
dialog title .title(<str>)
hint to show when input is empty .hint(<str>)
use a textarea with multiple lines .multipleLines()
enter the input as a password .password()
.download() Download a resource using the download manager
set the resource to download .url(<str>)
title for the download request .title(<str>)
description for the download request .description(<str>)
.infraredFrequencies() Query the infrared transmitter's supported carrier frequencies
.infraredTransmit() Transmit an infrared pattern
specify the pattern to transmit as array of numbers .frequency(<Array>)
.location() Get the device location
location provider (gps/network/passive) .provider(<enum>)
kind of request to make (once/last/updates) .request(<enum>)
.notification() Display a system notification
notification content to show .content(<str>)
notification id (will overwrite any previous notification with the same id) .id(<int>)
notification title to show .title(<str>)
notification url when clicking on it .url(<str>)
notification action when clicking on button1 .button1(<str>, <str>)
notification action when clicking on button2 .button2(<str>, <str>)
notification action when clicking on button3 .button3(<str>, <str>)
notification action when tapping on it .tap(<str>)
notification action when deleting it .delete(<str>)
notification image to show .image(<path>)
makes notification unremovable, need .id .pin()
.share() share a file specified as argument
provide a file to share .file(<path>)
which action to perform on the file (edit/send/view) .action(<enum>)
content-type to use (default: guessed from file extension) .contentType(<str>)
share to the default receiver instead of showing a chooser .default()
title to use for shared content (default: shared file name) .title(<str>)
.smsInbox() List received SMS messages
show dates when messages were created .date()
limit in sms list (default: 10) .limit(<int>)
show phone numbers .showNumbers()
offset in sms list (default: 0) .offset(<int>)
.smsSend() Send a SMS message to the specified recipient number(s)
Recipient number(s), gotta be an Array .numbers(<Array>)
The SMS text .text(<str>)
.telephonyCellInfo() Get information about all observed cell information from all radios on the device
.telephonyDeviceInfo() Get information about the telephony device
.ttsEngines() Get information about the available text-to-speech (TTS) engines
.ttsSpeak() Speak text with a system text-to-speech (TTS) engine
Text to speak, passed to the engine .text(<str>)
TTS engine to use, see .ttsEngines() .engine(<id>)
language to use (may be unsupported by the engine) .language(<enum>)
pitch to use in speech (1.0 is normal) .pitch(<num>)
speech rate to use (1.0 is normal) .rate(<num>)
audio stream to use (ALARM/MUSIC/NOTIFICATION/RING/SYSTEM/VOICE_CALL) .stream(<enum>)

Dependency

It uses has-termux-api to check if termux-api is installed.

Debug

Set the env DEBUG: DEBUG=termux

Author

Rocco Musolino (@roccomuso)

License

MIT

termux's People

Contributors

roccomuso avatar zfxstd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

termux's Issues

`.smsInbox()` doesn't work for `termux-sms-inbox` deprecation

~$ termux-sms-inbox
termux-sms-inbox: This script has been replaced by termux-sms-list.
~$ termux-sms-list -h
Usage: termux-sms-list [-d] [-l limit] [-n] [-o offset] [-t type] [-c] [-f number]
List SMS messages.
  -l limit   offset in sms list (default: 10)
  -o offset  offset in sms list (default: 0)
  -t type    the type of messages to list (default: all):
             all|inbox|sent|draft|outbox
  -c         conversation list (unique item per conversation)
  -f number  the number for locate messages
  -n         (obsolete) show phone numbers
  -d         (obsolete) show dates when messages were created

Since termux-sms-inbox has been deprecated, api.smsInbox().run() fails also.
Thus we need to add deprecation message in .smsInbox() and make a new method .smsList() and version upgrade the api since this would be a major change.

Install Failed

I am trying to install this, but I get this error:

npm ERR! code EPERM                               
npm ERR! syscall symlink                          
npm ERR! path ../semver/bin/semver                
npm ERR! dest /storage/emulated/0/
node/communitynotifier/
node_modules/.bin/semver                   
npm ERR! errno -1                                 
npm ERR! Error: EPERM: operation not 
permitted, symlink '../semver/bin/
semver' -> '/storage/emulated/0/node/
communitynotifier/node_modules/.bin/
semver'                                                 
npm ERR!  [Error: EPERM: operation not 
permitted, symlink '../semver/bin/
semver' -> '/storage/emulated/0/node/
communitynotifier/node_modules/.bin/
semver'] {                                            
npm ERR!   errno: -1,                             
npm ERR!   code: 'EPERM',                         
npm ERR!   syscall: 'symlink',                    
npm ERR!   path: '../semver/bin/semver',          
npm ERR!   dest: '/storage/emulated/0/
node/communitynotifier/
node_modules/.bin/semver'              
npm ERR! }                                        
npm ERR!                                          
npm ERR! The operation was rejected by 
your operating system.                                       
npm ERR! It is likely you do not have the 
permissions to access this file as the
current user       
npm ERR!                                          
npm ERR! If you believe this might be a permissions issue, please double-check the                  
npm ERR! permissions of the file and its 
containing directories, or try running                     
npm ERR! the command again as root/
Administrator.                                                   
npm ERR! A complete log of this run can 
be found in:                                                
npm ERR!     /data/data/com.termux/
files/home/.npm/_logs/
2021-09-05T18_23_55_855Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.