line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Termux::API; |
2
|
1
|
|
|
1
|
|
68188
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
702
|
use JSON; |
|
1
|
|
|
|
|
12774
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.03; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
1
|
|
return bless( { |
10
|
|
|
|
|
|
|
j => JSON->new |
11
|
|
|
|
|
|
|
}, $_[0] ); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub command { |
15
|
0
|
|
|
0
|
1
|
|
my $command = qx($_[1]); |
16
|
0
|
|
0
|
|
|
|
return eval { $_[0]->{j}->decode($command) } || $command; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub battery_status { |
20
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-battery-status'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub brightness { |
24
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-brightness $_[1]"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub camera_info { |
28
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-camera-info'); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub clipboard_get { |
32
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-clipboard-get'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub clipboard_set { |
36
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-clipboard-set $_[1]"); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub contact_list { |
40
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-contact-list'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub dialog { |
44
|
0
|
|
|
0
|
1
|
|
my ( $self, $type, %options ) = @_; |
45
|
|
|
|
|
|
|
my $command = sprintf( 'termux-dialog %s %s', |
46
|
|
|
|
|
|
|
$type, |
47
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
); |
49
|
0
|
|
|
|
|
|
$_[0]->command($command); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub download { |
53
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-download $_[1]"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub fingerprint { |
57
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-fingerprint'); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub infrared_frequencies { |
61
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-infrared-frequencies'); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub infrared_transmit { |
65
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-infrared-transmit -f $_[1]"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub location { |
69
|
0
|
|
|
0
|
1
|
|
my ( $self, $provide, $request ) = @_; |
70
|
0
|
|
0
|
|
|
|
$provide ||= 'gps'; |
71
|
0
|
|
0
|
|
|
|
$request ||= 'once'; |
72
|
0
|
|
|
|
|
|
$_[0]->command("termux-location -p $provide -r $request"); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub microphone { |
76
|
0
|
|
|
0
|
1
|
|
my ( $self, %options ) = @_; |
77
|
|
|
|
|
|
|
my $command = sprintf( 'termux-microphone-record %s', |
78
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
); |
80
|
0
|
|
|
|
|
|
$_[0]->command($command); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub notification { |
84
|
0
|
|
|
0
|
1
|
|
my ( $self, %options ) = @_; |
85
|
|
|
|
|
|
|
my $command = sprintf( 'termux-notification %s', |
86
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
); |
88
|
0
|
|
|
|
|
|
$_[0]->command($command); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub notification_remove { |
92
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-notification-remove $_[1]"); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub sensor { |
96
|
0
|
|
|
0
|
1
|
|
my ( $self, %options ) = @_; |
97
|
0
|
|
|
|
|
|
$options{'-n'} = 1; |
98
|
|
|
|
|
|
|
my $command = sprintf( 'termux-sensor %s', |
99
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
); |
101
|
0
|
|
|
|
|
|
$_[0]->command($command); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub telephony_call { |
105
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-telephony-call $_[1]"); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub telephony_cellinfo { |
109
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-telephony-cellinfo'); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub telephony_device { |
113
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-telephony-deviceinfo'); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub toast { |
117
|
0
|
|
|
0
|
1
|
|
my ( $self, $text, %options ) = @_; |
118
|
|
|
|
|
|
|
my $command = sprintf( |
119
|
|
|
|
|
|
|
'termux-toast %s "%s"', |
120
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ), |
|
0
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$text |
122
|
|
|
|
|
|
|
); |
123
|
0
|
|
|
|
|
|
$_[0]->command($command); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub torch { |
127
|
0
|
|
|
0
|
1
|
|
$_[0]->command("termux-torch $_[1]"); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub tts_engines { |
131
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-tts-engines'); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub tts_speak { |
135
|
0
|
|
|
0
|
1
|
|
my ( $self, $text, %options ) = @_; |
136
|
|
|
|
|
|
|
my $command = sprintf( |
137
|
|
|
|
|
|
|
'termux-tts-speak %s "%s"', |
138
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ), |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$text |
140
|
|
|
|
|
|
|
); |
141
|
0
|
|
|
|
|
|
$_[0]->command($command); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub vibrate { |
145
|
0
|
|
|
0
|
1
|
|
my ( $self, %options ) = @_; |
146
|
|
|
|
|
|
|
my $command = sprintf( 'termux-vibrate %s', |
147
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
); |
149
|
0
|
|
|
|
|
|
$_[0]->command($command); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub volume { |
153
|
0
|
|
|
0
|
1
|
|
my ( $self, $stream, $volume ) = @_; |
154
|
0
|
|
|
|
|
|
my $command = 'termux-volume'; |
155
|
0
|
0
|
0
|
|
|
|
if ( $stream and $volume ) { |
156
|
0
|
|
|
|
|
|
$command = sprintf( '%s %s %s', $command, $stream, $volume ); |
157
|
|
|
|
|
|
|
} |
158
|
0
|
|
|
|
|
|
$self->command($command); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub wallpaper { |
162
|
0
|
|
|
0
|
1
|
|
my ( $self, %options ) = @_; |
163
|
|
|
|
|
|
|
my $command = sprintf( 'termux-wallpaper %s', |
164
|
0
|
|
|
|
|
|
join( ' ', map( { $_ . ' "' . $options{$_} . '"'; } keys %options ) ) |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
); |
166
|
0
|
|
|
|
|
|
$self->command($command); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub wifi { |
170
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-wifi-connectioninfo'); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub wifi_enable { |
174
|
0
|
0
|
|
0
|
1
|
|
my $enable = $_[1] ? 'true' : 'false'; |
175
|
0
|
|
|
|
|
|
$_[0]->command("termux-wifi-enable $enable"); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub wifi_scan { |
179
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-wifi-scaninfo'); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub audio_info { |
183
|
0
|
|
|
0
|
1
|
|
$_[0]->command('termux-audio-info'); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub elf_cleaner { |
187
|
0
|
|
|
0
|
1
|
|
my ($self, @files) = @_; |
188
|
0
|
|
|
|
|
|
$self->command(sprintf 'termux-elf-cleaner %s', join ' ', @files); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub speech_to_text { |
192
|
0
|
0
|
|
0
|
1
|
|
$_[0]->command(sprintf( |
193
|
|
|
|
|
|
|
'termux-speech-to-text %s', |
194
|
|
|
|
|
|
|
$_[1] ? '-p' : '' |
195
|
|
|
|
|
|
|
)); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |