Termux::API - Termux::API wrapper
Version 1.00
Quick summary of what the module does.
pkg install make pkg install clang pkg install perl curl -L https://cpanmin.us | perl - App::cpanminus cpanm Termux::API; ... use Termux::API; my $termux = Termux::API->new(); $termux->toast('testing a toast');
Termux is an Android terminal emulator and Linux environment application that works directly with no rooting or setup required. A minimal base system is installed automatically, additional packages are available using the package manager.
Termux::API allows you to access Android and Chrome hardware features.
Instantiate a new Termux::API::Tiny Object.
my $termux = Termux::API::Tiny->new;
Initiate a termux api command
$termux->command("termux-battery-status")
Get the status of the device battery.
$termux->battery_status
Set the display brightness. Note that this may not work if automatic brightness control is enabled.
$termux->brightness
Get information about device camera(s).
$termux->camera_info
Get the system clipboard text
$termux->clipboard_get
Set the system clipboard text.
$termux->clipboard_set("copy some text")
List all contacts
$termux->contact_list
Show dialog widget for user input
$termux->dialog("confirm", -i => "Hint text", -t => "Title text")
Options:
confirm - Show confirmation dialog [-i hint] text hint (optional) [-t title] set title of dialog (optional) checkbox - Select multiple values using checkboxes [-v ",,,"] comma delim values to use (required) [-t title] set title of dialog (optional) counter - Pick a number in specified range [-r min,max,start] comma delim of (3) numbers to use (optional) [-t title] set title of dialog (optional) date - Pick a date [-t title] set title of dialog (optional) [-d "dd-MM-yyyy k:m:s"] SimpleDateFormat Pattern for date widget output (optional) radio - Pick a single value from radio buttons [-v ",,,"] comma delim values to use (required) [-t title] set title of dialog (optional) sheet - Pick a value from sliding bottom sheet [-v ",,,"] comma delim values to use (required) [-t title] set title of dialog (optional) spinner - Pick a single value from a dropdown spinner [-v ",,,"] comma delim values to use (required) [-t title] set title of dialog (optional) speech - Obtain speech using device microphone [-i hint] text hint (optional) [-t title] set title of dialog (optional) text - Input text (default if no widget specified) [-i hint] text hint (optional) [-m] multiple lines instead of single (optional)* [-n] enter input as numbers (optional)* [-p] enter input as password (optional) [-t title] set title of dialog (optional) * cannot use [-m] with [-n] time - Pick a time value [-t title] set title of dialog (optional)
Download a resource using the system download manager.
$termux->download($url)
Use fingerprint sensor on device to check for authentication.
$termux->fingerprint
Query the infrared transmitter's supported carrier frequencies.
$termux->infrared_frequencies
Transmit an infrared pattern.
$termux->infrared_transmit($pattern)
Get the device location. You can optionally pass a provider (gps|network|passive) and a kind of request (once|last|updates).
$termux->location($provider, $request)
Record using microphone on your device.
$termux->sensor(-s => "gravity")
OPTIONS:
-h, help Show this help -a, all Listen to all sensors (WARNING! may have battery impact) -c, cleanup Perform cleanup (release sensor resources) -l, list Show list of available sensors -s, sensors [,,,] Sensors to listen to (can contain just partial name) -d, delay [ms] Delay time in milliseconds before receiving new sensor update -n, limit [num] Number of times to read sensor(s) (default: continuous) (min: 1)
Display a system notification.
$termux->notification(-i => 1, -t => "Title text", -c => "Content text")
--action action action to execute when pressing the notification --alert-once do not alert when the notification is edited --button1 text text to show on the first notification button --button1-action action action to execute on the first notification button --button2 text text to show on the second notification button --button2-action action action to execute on the second notification button --button3 text text to show on the third notification button --button3-action action action to execute on the third notification button -c/--content content content to show in the notification. Will take precedence over stdin. --group group notification group (notifications with the same group are shown together) -h/--help show this help --help-actions show the help for actions -i/--id id notification id (will overwrite any previous notification with the same id) --image-path path absolute path to an image which will be shown in the notification --led-color rrggbb color of the blinking led as RRGGBB (default: none) --led-off milliseconds number of milliseconds for the LED to be off while it's flashing (default: 800) --led-on milliseconds number of milliseconds for the LED to be on while it's flashing (default: 800) --on-delete action action to execute when the the notification is cleared --ongoing pin the notification --priority prio notification priority (high/low/max/min/default) --sound play a sound with the notification -t/--title title notification title to show --vibrate pattern vibrate pattern, comma separated as in 500,1000,200 --type type notification style to use (default/media)
Remove a notification previously shown with "termux-notification -i"
$termux->notification_remove(1)
Get information about types of sensors as well as live data.
Call a telephony number.
$termux->telephony_call($number)
Get information about all observed cell information from all radios on the device including the primary and neighboring cells.
$termux->telephony_cellinfo
Get information about the telephony device.
Show text in a Toast (a transient popup).
$termux->toast("Test a toast", %options)
-h show this help -b set background color (default: gray) -c set text color (default: white) -g set position of toast: [top, middle, or bottom] (default: middle) -s only show the toast for a short while
Toggle LED Torch on device. Accepts either on (enable torch) or off (disable torch.
$termux->torch('on')
Get information about the available text-to-speech (TTS) engines.
$termux->tts_engines
Speak text with a system text-to-speech (TTS) engine. TODO
$termux->tts_speak("Talk to me")
-e engine TTS engine to use (see termux-tts-engines) -l language language to speak in (may be unsupported by the engine) -n region region of language to speak in -v variant variant of the language to speak in -p pitch pitch to use in speech. 1.0 is the normal pitch, lower values lower the tone of the synthesized voice, greater values increase it. -r rate speech rate to use. 1.0 is the normal speech rate, lower values slow down the speech (0.5 is half the normal speech rate) while greater values accelerates it (2.0 is twice the normal speech rate). -s stream audio stream to use (default:NOTIFICATION), one of: ALARM, MUSIC, NOTIFICATION, RING, SYSTEM, VOICE_CALL
Vibrate the device.
$termux->vibrate
-d duration the duration to vibrate in ms (default:1000) -f force vibration even in silent mode
View or Change volume of specified audio stream
$termux->volume
Change wallpaper on your device.
$termux->wallpaper(%options)
-f <file> set wallpaper from file -u <url> set wallpaper from url resource -l set wallpaper for lockscreen (Nougat and later)
Get information about current Wi-Fi connection. This information include: SSID (AP name), BSSID (AP mac address), device IP and other.
$termux->wifi
Toggle Wi-Fi on or off
$termux->wifi_enable(1)
Retrieves last wifi scan information.
$termux->wifi_scan
Get information about audio capabilities.
$termux->audio_info
Utility for Android ELF files to remove unused parts that the linker warns about.
$termux->elf_cleaner(@files)
Converts speech to text, sending partial matches to stdout.
$termux->speech_to_text($show_progress)
LNATION, <email at lnation.org>
<email at lnation.org>
Please report any bugs or feature requests to bug-termux::api at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Termux-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-termux::api at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Termux::API
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Termux-API
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Termux-API
CPAN Ratings
https://cpanratings.perl.org/d/Termux-API
Search CPAN
https://metacpan.org/release/Termux-API
This software is Copyright (c) 2020 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Termux::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Termux::API
CPAN shell
perl -MCPAN -e shell install Termux::API
For more information on module installation, please visit the detailed CPAN module installation guide.