Termux-API
view release on metacpan or search on metacpan
lib/Termux/API.pm view on Meta::CPAN
package Termux::API;
use strict;
use warnings;
use JSON;
our $VERSION = '1.01';
sub new {
return bless( {
j => JSON->new
}, $_[0] );
}
sub command {
my $command = qx($_[1]);
return eval { $_[0]->{j}->decode($command) } || $command;
}
sub battery_status {
$_[0]->command('termux-battery-status');
}
sub brightness {
$_[0]->command("termux-brightness $_[1]");
}
sub camera_info {
$_[0]->command('termux-camera-info');
}
sub clipboard_get {
$_[0]->command('termux-clipboard-get');
}
sub clipboard_set {
$_[0]->command("termux-clipboard-set $_[1]");
}
sub contact_list {
$_[0]->command('termux-contact-list');
}
sub dialog {
my ( $self, $type, %options ) = @_;
my $command = sprintf( 'termux-dialog %s %s',
$type,
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) )
);
$_[0]->command($command);
}
sub download {
$_[0]->command("termux-download $_[1]");
}
sub fingerprint {
$_[0]->command('termux-fingerprint');
}
sub infrared_frequencies {
$_[0]->command('termux-infrared-frequencies');
}
sub infrared_transmit {
$_[0]->command("termux-infrared-transmit -f $_[1]");
}
sub location {
my ( $self, $provide, $request ) = @_;
$provide ||= 'gps';
$request ||= 'once';
$_[0]->command("termux-location -p $provide -r $request");
}
sub microphone {
my ( $self, %options ) = @_;
my $command = sprintf( 'termux-microphone-record %s',
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) )
);
$_[0]->command($command);
}
sub notification {
my ( $self, %options ) = @_;
my $command = sprintf( 'termux-notification %s',
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) )
);
$_[0]->command($command);
}
sub notification_remove {
$_[0]->command("termux-notification-remove $_[1]");
}
sub sensor {
my ( $self, %options ) = @_;
lib/Termux/API.pm view on Meta::CPAN
Version 1.01
=cut
=head1 SYNOPSIS
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');
=head1 DESCRIPTION
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.
=head1 SUBROUTINES/METHODS
=head2 new
Instantiate a new Termux::API::Tiny Object.
my $termux = Termux::API::Tiny->new;
=head2 command
Initiate a termux api command
$termux->command("termux-battery-status")
=head2 battery_status
Get the status of the device battery.
$termux->battery_status
=head2 brightness
Set the display brightness. Note that this may not work if automatic brightness control is enabled.
$termux->brightness
=head2 camera_info
Get information about device camera(s).
$termux->camera_info
=head2 clipboard_get
Get the system clipboard text
$termux->clipboard_get
=head2 clipboard_set
Set the system clipboard text.
$termux->clipboard_set("copy some text")
=head2 contact_list
List all contacts
$termux->contact_list
=head2 dialog
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)
=head2 download
( run in 3.309 seconds using v1.01-cache-2.11-cpan-84e82930d8c )