A program can ask the app exshell for things of the phone: a short note, a notification, the clipboard, a floating window, a page, a picture, sound. There are two ways. Every word has an example.
The app listens on a socket in its own folder (the variable EXSHELL_API): only the programs of exshell reach it. In the shell:
| Word | What it does | Example |
|---|---|---|
toast TEXT |
a short note on the screen | ex toast "build done" |
notify TITLE TEXT |
a notification | ex notify Backup "finished" |
copy TEXT / paste |
the clipboard (Android gives it only while exshell is in front) | ex copy hello · ex paste |
vibrate [MS] |
the phone vibrates | ex vibrate 300 |
| `torch on | off` | the flash light |
battery |
87 charging or 42 on battery |
ex battery |
open FILE-OR-LINK |
open it with the app of the phone that knows it | ex open photo.jpg · ex open https://example.org |
share FILE / send TEXT |
the share screen of Android | ex share report.pdf |
| `pick image | file` | the person chooses; prints the path of a copy |
apk FILE |
the installer of Android | ex apk app.apk |
apps / launch NAME |
the apps of the phone / start one | ex apps · ex launch Chrome |
call NUMBER |
opens the dialler (it does not call by itself) | ex call 191 |
tab COMMAND |
a new session that runs the command | ex tab "ping 8.8.8.8" |
popup [COMMAND] |
a floating session | ex popup top |
exit |
close the app | ex exit |
api |
the words the app knows | ex api |
More words are for programs that use the library (jex install exapi, then #import <exapi>): Ex::toast(text), Ex::notify(title, text), Ex::copy(text), Ex::paste(), Ex::vibrate(ms), Ex::torch(on), Ex::battery(), Ex::open(x), Ex::share(f), Ex::pick(kind), Ex::apps(), Ex::launch(name), Ex::tab(cmd), Ex::popup(cmd), Ex::play(file), Ex::pause(), Ex::resume(), Ex::stop(), Ex::set(key, value), Ex::get(key), Ex::awake(on), Ex::version().
play, pause, resume, stop, set, get, awake and version are not words of the ex command (films and songs are jvp4 play FILE; settings are ex set KEY VALUE).
#import <exapi>
void main() { if Ex::inside() { Ex::notify("done", "the build passed"); } }
For a program that owns the terminal (it can read the answers). In a shell: printf '\033]7777;notify;Done;It worked\007'. The answer, when there is one, comes as typed letters in the same format: a program reads it in raw mode (no echo), like mipo and image do. A text that a page or a file could write is sent in base64.
| Message | What it does | Example | Answer |
|---|---|---|---|
notify;TITLE;TEXT |
a notification | \033]7777;notify;Done;ok\007 |
— |
open;PATH |
open a file with the app of the phone | \033]7777;open;/sdcard/a.pdf\007 |
— |
intent;view;URL · send;TEXT · share;PATH · call;NUMBER · app;NAME · pick;image · apps |
other screens of the phone | \033]7777;intent;view;https://example.org\007 |
intent-ok, intent-error;TEXT, intent-apps;BASE64, pick gives the path |
session;new;COMMAND · session;popup;COMMAND |
a new session / a floating one that runs a command | \033]7777;session;popup;top\007 |
— |
theme;NAME · font;PIXELS · reload · restart · `volkeys;on |
off` | the look of the app | \033]7777;theme;black\007 |
settings;list · set;KEY;VALUE · get;KEY |
the settings (the answer is written on the screen) | \033]7777;set;window_theme;pixel-arcane\007 |
on the screen |
audio;play;PATH · pause · resume · stop · seek;MS · volume;0..100 · pos |
sound | \033]7777;audio;play;/sdcard/a.mp3\007 |
pos;MS;STATE;LENGTH (STATE 0 stopped, 1 playing, 2 paused) · audio-error;TEXT |
video;play;PATH · stop · pause · resume · seek;MS · pos |
a film in a floating window with a time bar | \033]7777;video;play;/sdcard/f.mp4\007 |
video-pos;MS;STATE;LENGTH · video-end · video-error;TEXT |
gfx;open;W;H;PATH · gfx;present · gfx;close |
a picture of dots in a window: the program writes W x H x 4 bytes (blue, green, red, alpha) into PATH and says present (at most 1920 x 1080) |
the library gamelib does it |
`touch;D |
| `camera;open;SIDE;PATH;MEGADOTS;MODE[;float | full]·shot;PATH·flip·mode;photo |
scan | video·torch;on |
web;open;ADDRESS · reload · stop · back · forward · close |
a page in a floating window (http and https; http only for localhost) | mipo open localhost:8000 |
web-load;URL;TITLE · web-console;LEVEL;TEXT;SOURCE · web-error;TEXT;URL · web-blocked;URL · web-refused;TEXT (the address is not taken: end at once) · web-closed (texts in base64) |
web;watch;on · off |
tell every request of the page (the page, scripts, pictures, calls) | mipo open URL -v |
web-request;METHOD;URL (URL in base64) |
web;clear |
forget the cookies (logins) and the data of the sites | mipo forget |
web-cleared |
img;decode;PATH;PAGE;MAXW;MAXH;OUT |
the app decodes a picture of any kind (JPEG, PNG, GIF, WebP, BMP, HEIF) or one page of a PDF into dots in OUT, which must be a file of the tmp folder of the app (PATH and OUT in base64) | image doc.pdf |
img-ok;W;H;PAGES;PAGE · img-error;TEXT |
An unknown message is ignored. The answers of web, video, camera and img are typed into the terminal: only a program that reads them should send the message (a shell would show the letters).
There is no socket word yet for the web window, the screen window or the camera (only the messages above), so a program without a terminal cannot open them. Ask for it, and it can be added.