Git Product home page Git Product logo

termux-api's Introduction

Termux API

Build status Join the chat at https://gitter.im/termux/termux

This is an app exposing Android API to command line usage and scripts or programs.

When developing or packaging, note that this app needs to be signed with the same key as the main Termux app for permissions to work (only the main Termux app are allowed to call the API methods in this app).

Installation

Termux:API application can be obtained from F-Droid.

Additionally we provide per-commit debug builds for those who want to try out the latest features or test their pull request. This build can be obtained from one of the workflow runs listed on Github Actions page.

Signature keys of all offered builds are different. Before you switch the installation source, you will have to uninstall the Termux application and all currently installed plugins. Check https://github.com/termux/termux-app#Installation for more info.

License

Released under the GPLv3 license.

How API calls are made through the termux-api helper binary

The termux-api client binary in the termux-api package generates two linux anonymous namespace sockets, and passes their address to the TermuxApiReceiver broadcast receiver as in:

/system/bin/am broadcast ${BROADCAST_RECEIVER} --es socket_input ${INPUT_SOCKET} --es socket_output ${OUTPUT_SOCKET}

The two sockets are used to forward stdin from termux-api to the relevant API class and output from the API class to the stdout of termux-api.

Client scripts

Client scripts which processes command line arguments before calling the termux-api helper binary are available in the termux-api package.

Ideas

  • Wifi network search and connect.
  • Add extra permissions to the app to (un)install apps, stop processes etc.

termux-api's People

Contributors

abdullahm0hamed avatar agnostic-apollo avatar auxilus avatar benmoran avatar bsg avatar cvirostek avatar dependabot[bot] avatar dkramer95 avatar epictek avatar fornwall avatar grimler91 avatar gsf avatar gungsukma avatar its-pointless avatar landfillbaby avatar mrfishfinger avatar nenadilic84 avatar pimsierhuis avatar povidalo avatar rsanjuan87 avatar schoentoon avatar svyatoslav2 avatar tareksander avatar tomty89 avatar tstein avatar wetitpig avatar wzaw1 avatar xalexalex avatar yurimataev avatar zepplu 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  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

termux-api's Issues

No response on Asus devices

I have installed the App and the package, but when I run any command of the API it just blocks until I cancel it with CTRL-C.
Displaying the help (-h) works though.

termux-notification -u : set mime type

noticed that it won't set any mime type, this works for urls starting as "http://" but fails with "file://" . Setting mime to text/html makes that work.

Perhaps an option to specify the mime type explicitly would good?

termux commands not responding

Hello

I installed the termux application, installed the API from the app store, updated the app on the phone, installed the termux api inside the termux app. I cannot get any of the functions to run except for the -help function. When I try running the application I have the application that just sits there and does nothing.

Android version: 5.0
Phone: asus zenfone 2

What should I try doing to get the functions to work.

Idea/Question: REST-API

I like to make/have termux-api available via REST, for example:

Android:

% termux-rest &

PC:

% curl 'http://192.168.2.100:8091/camera-photo?c=1'

retrieves JPEG direct

% curl http://192.168.2.100:8091/camera-info

retrieves JSON

etc. essentially http://x.x.x.x:port/(\w+)?(.+) -> termux-$1 $2 (with some proper argument parsing)

Question: what would be the easiest way (programming framework) to implement this lightweight http server providing the functionality?

I quickly coded (2hr) perl script which implements basic web-server which calls termux-* (with simple argument parsing) and takes output to return to http GET request, yet, it might be more suitable to use termux-api.c direct and put a small web-server into it, which connects to the internal API instead via termux-* -> termux-api -> am -> tcp.

I like to probe multiple android phones for battery info (actually the battery temperature is what I care about) and take photos via REST, turning Android smartphones into IoT devices.

My quick hack does this, accessing http://192.168.2.100:8091/ gives an overview of the services:

termux-rest (0.0.2) services:
   battery-status
   camera-info
   camera-photo: c=<...>
   location
   telephony-cellinfo
   telephony-deviceinfo
   tts-engines
   tts-speak: speak=<...>
   vibrate

with Content-Type: text/html, each service listed is a link.

and http://192.168.2.100:8091/battery-status:

{
  "health": "GOOD",
  "percentage": 97,
  "plugged": "UNPLUGGED",
  "status": "DISCHARGING",
  "temperature": 23.600000381469727
}

with Content-Type: application/json and CORS set so XHR JavaScript requests can be made.

termux-camera-photo: back facing camera does not work

Backwards facing camera, id 0, produces empty file:

$ termux-camera-photo -c 0 camera0.jpg
$ ls -l
total 0
-rw------- 1 u0_a260 u0_a260 0 Mar 21 15:32 camera0.jpg

Frontfacing camera, id 1, works just fine:

$ termux-camera-photo -c 1 camera1.jpg
$ ls -l
total 244
-rw------- 1 u0_a260 u0_a260 0 Mar 21 15:32 camera0.jpg
-rw------- 1 u0_a260 u0_a260 247734 Mar 21 15:33 camera1.jpg

Device: Samsung Galaxy S4 Active
Model number: GT-I9295
Android version: 5.0.1

$ termux-camera-info
[
{
"id": "0",
"facing": "back",
"jpeg_output_sizes": [
{
"width": 3264,
"height": 2448
},
{
"width": 3264,
"height": 1836
},
{
"width": 2048,
"height": 1536
},
{
"width": 2048,
"height": 1152
},
{
"width": 1920,
"height": 1080
},
{
"width": 1280,
"height": 720
},
{
"width": 640,
"height": 480
}
],
"focal_lengths": [
3.700000047683716
],
"auto_exposure_modes": [
"CONTROL_AE_MODE_ON",
"CONTROL_AE_MODE_ON_AUTO_FLASH",
"CONTROL_AE_MODE_ON_ALWAYS_FLASH"
],
"physical_size": {
"width": 3.8357956409454346,
"height": 2.8777027130126953
},
"capabilities": [
"backward_compatible"
]
},
{
"id": "1",
"facing": "front",
"jpeg_output_sizes": [
{
"width": 1920,
"height": 1080
},
{
"width": 1440,
"height": 1080
},
{
"width": 1392,
"height": 1392
},
{
"width": 1280,
"height": 720
},
{
"width": 960,
"height": 720
},
{
"width": 640,
"height": 480
}
],
"focal_lengths": [
1.850000023841858
],
"auto_exposure_modes": [
"CONTROL_AE_MODE_ON"
],
"physical_size": {
"width": 0.03228941187262535,
"height": 0.03228941187262535
},
"capabilities": [
"backward_compatible"
]
}
]

Listen to incoming SMS?

Hello! I would like to implement the following:
When SMS arrives, my computer shows me a notification with it's text and sender.
That's how I see the implementation: using termux, somehow listen to incoming sms, and if sms comes, parse termux-sms-inbox output and pipe it to netcat, on desktop listen to netcat and handle incoming info. Could you please give me a piece of advice on how to listen to incoming sms? Of course, I can run termux-sms-inbox regularly and compare output, but it doesn't seem to be an effective way of doing it. Thanks in advance.

FYI: termux-api in Go!

Hey folks,

Thought you'd find this interesting; I rewrote in Go the C tool and scripts from the termux-api tools normally installed through apt to use this App. In theory, this means you can compile Go apps that make calls to termux-api to use the APIs from Go.

Lots of it is completely untested, including things like "sending Stdin down a Unix pipe". Only some tools have been tested at all.

Also, the struct values for SMS messages from SmsInbox and from TTS engines are currently unknown because I get no results for these on my phone (SMSsecure protects sms, and no TTS engines).

Thanks for a great app, I'm looking forward to playing with pure-Go pseudo-apps thanks to Termux. :)

termux-api depends on /system/bin

Hi.
The latest update of the main app broke the api. For example termux-battery-statusyields:
"/system/bin/am[8]: app_process: not found"
After adding /system/bin back to the $PATH will make it work again.

I can't install termux-api

When I install by executing "apt install termux-ap" it say "Unable to locate package termux-api".
I install termux-api from Google Play.

Can't install Termux:Api from google play on Nougat.

I've tried to install Termux:Api on a rooted Nexus 6P running Nougat (7.1.1 Build NMF26F).
I've tried rebooting and clearing google play cache. To no avail.
Google Play issues the following errorcode -505, which to my understanding is a catch-all for various errors.
The device has sufficient storage memory.
The same happens when trying to install Termux:Task on that device.

API request for screenshots

Is there any plan to add a screenshot API, which I think will be really useful. I know there's an screencap command but that requires root privilege.
Cheers!

termux-tts-speak volume cannot be adjusted

The stream, AudioManager.STREAM_SYSTEM is not adjustable on my Android 5.0 Asus Fonepad through the volume control app. I tried adjusting the STREAM_SYSTEM volume manually through a Rhino JS tool (Scriptit), but although I can adjust the STREAM_MUSIC that way, STREAM_SYSTEM stays at full volume.

Other tts systems seem to use either STREAM_DEFAULT or STREAM_MUSIC. Are there constraints which cause termux to use STREAM_SYSTEM?

Feature request: remove item from clipboard

I would like to see an option on termux-clipboard-set or a new command that allows you to remove items from the clipboard. For example, when copying a password from pass, I want the password to be deleted from the clipboard after a certain amount of time.

Control notification led

I would like to have a command to control the notification led. I would want to be able to toggle it, set it to blink and choose color.
There is an interface in /sys/class/leds but it requires root.

ctrl+shit++ key not increasing text size

Not sure where else to post this. I don't have a G+ account (and never will).

The sequence ctrl+shift++ is not working on my k810 bluetooth keyboard (tenkey less). I think since the + requires shift to register and shift is already being used for the sequence the text size increment is not registering.

Feature Request: termux-dialog more dialogs / widgets / controls please! :) like list, multiselect list, etc

Here is feature request for more widgets / controls / dialogs for termux-dialog . Like dialog unix ncourses equivalent offer multiple more options including: radio lists, multiple choice lists, "menu", progressbar, timebox, calendar (with --date-format option), etc...

I would appreciate arguments compatibility so script could easily switch between dialog and termux-dialog depending on tool availability.

I am glad I can still use standard dialog unix tool and interact via touch on Android device, but how nice would it be to interact with potential user via native Android UI?

Thankd a lot for whole work - so far enjoying dialog on Android :)

Add license information

I suspect it's GPLv3, but it would be nice to have that stated in the readme or a special license file.

Feature request: Hide / Show Keyboard

Hi
A command that would allow us to hide and show the software keyboard.
termux-keyboard-show / termux-keyboard-hide

This would allow for scripts that automatically go into 'fullscreen' at the start and show the keyboard again when it is done.

Additionally something like termux-keyboard-visible would also be very usefull, to check whether the keyboard is present to begin with.
Example:

isKeyboardVisible=$(termux-keyboard-visible)
termux-keyboard-hide
./presentation.sh
if [ $isKeyboardVisible ]; then
  termux-keyboard-show
endif

tts-speak: implement embedded speech commands

Apple tts has a nice sugarcandy which would be incredibly useful in shell scripts - the possibility to embed commands into the text such as [[emph +]], [[slnc 6000]], [[volm +0.4]]. Could also use [[beep duration pitch]] or [[play file.ogg]] which apple does not seem to have.

https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html

I found the Android Pico TTS supports it (Chapter 7 of its documentation) and a few related stackoverflow posts:
http://stackoverflow.com/questions/3495301/best-practice-for-specifying-pronunciation-for-android-tts-engine
http://stackoverflow.com/questions/3495301/best-practice-for-specifying-pronunciation-for-android-tts-engine

Not sure if it can work without speacial help of termux-api?

/system/bin/sh: Permission denied

I am using s5 version 5.0 , i am using rooted cell .when i try to execute make . Its saying permission denied.
make: execvp: /system/bin/sh: Permission denied

termux-share shares the file as "datastream"

I thought of termux-share as kde-open or gnome-open or cygstart. However, its behavior is different. When I open a text file using termux-share (as in example below), my editor (QuickEdit Pro) receives a file with url
content://com.termux.sharedfiles//storage/emulated/0/x.txt, which the editor app cannot save.
However, when I locate the file in a file manager and then open it, the url is correct
/storage/emulated/0/x.txt, and the editor app can save my changes.
How can termux-share open files in other apps just like my file manager does.

$ ls
x.txt
$termux-share x.txt

/system/bin/am: Permission denied

Hi,

I am using an lg g3 and not any custom rom and i did not rooted my device.
I installed termux-api app and updated and upgraded my apt too.
However when i want to call any termux api command in the termux terminal, i see this error message:
/data/data/com.termux/files/usr/bin/am: 3: exec: /system/bin/am: Permission denied

termux-fix-shebang : fails when incompatible cr/lf

happened to share a script by email (k9mail) and the attachment was mangled to contain "\r" at line ends.

termux-fix-shebang fixed the path but not the "\r", resulting in a rather "mysterious" error message.

dos2unix fixed it.

Btw.. isn't there some way to workaround to avoid needing to fix shebang paths at least for the primary shell?

termux-location: empty output

Already mentioned in g+:
$ termux-location
yields empty output
$ termux-location -r last
{
"API_ERROR": "Failed to get location"
}

Have same behaviour on two different devices both running CM12
// don't have environment for debugging yet

Clipboard commands hang

When I pipe text into termux-clipboard-set or run termux-clipboard-get, the command just hangs. To get my prompt back, I have to use ctrl-c.

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.