• Stars
    star
    570
  • Rank 78,245 (Top 2 %)
  • Language
    Kotlin
  • License
    GNU General Publi...
  • Created about 3 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A plugin for Termux to use native Android GUI components from CLI applications.

Termux:GUI

This is a plugin for Termux that enables command line programs to use the native android GUI.

In the examples directory you can find demo videos, sample code is provided in the tutorials of the official language bindings.

There are also prepackaged programs you can use.

Installation notes
There is currently no release on f-droid, so the only method to install this plugin is to use the apk from the releases and the Termux apk from Github Actions.
Releases on f-droid will be provided as soon as possible. When there is a release, the f-droid badge at the top will show a version number. The f-droid builds currently don't work, Github builds are the only option for now.
See this comment for links to install Termux and its plugins from Github.

Protocol.md describes the Protocol used and the available functions you can use.
GUIProt0.proto contains teh documentation of the newer Protobuf-based protocol with more features.
If you want to use overlay windows or be able to open windows from the background, go into the app settings for Termux:GUI, open the advanced section and enable "Display over other apps".

Features

  • buttons, switches, toggles, checkboxes, text fields, scrolling, LinearLayout
  • custom notifications
  • custom widgets
  • shared image buffers
  • GLES2 acceleration
  • WebView
  • Dialogs
  • Lockscreen Activities
  • Wake-lock
  • ...and more

Comparison with native apps

Native app With Termux:GUI
Has to be installed Program can be run in Termux
Full access to the Android API Access to the Android API through Termux:GUI and Termux:API
Limited to C, C++, Kotlin and Java for native development Any programming language can be used, prebuilt library for python available
Lower performance caused by IPC
Accessing files in Termux only possible via SAF Direct access to files in Termux
Has to be started with am from Termux Can be started like any other program in Termux
Can receive command line arguments and output back to the Terminal

Language Bindings

Official

Community

Not maintained by the plugin maintainer:

Using the plugin

Using this plugin requires a bit of knowledge of the Android GUI system. You can read about it in detail in the official documentation.
Relevant documentation is also linked in Protocol.md for more specific subjects.
Here is a crash-course:

Tasks

Tasks are the individual screens you can switch between. Each Task has a stack of Activities, called the back stack, with the top one being visible.

Activities

Activities are the individual screens of apps, like a home screen, a settings screen etc.
When an Activity finishes itself, it is removed from the Activity stack of its Task, showing the underlying Activity.
An Activity can also launch another Activity in the Task, adding it to the back stack on top of itself.
To not let the device do unneeded work like drawing Elements that aren't visible, the System informs Activities of certain changes.
These are the Activity lifecycle events.

Activity Lifecycle

The most important lifecycle events for you will be onDestroy, onStart and onStop. When an Activity is started, it is visible. An Activity is destroyed if the user finishes it (by dismissing it), when it finishes itself or when a configuration change occurs.
The plugin will tell you if the Activity is finishing when onDestroy is fired, so you know the Activity will be closed.
Configuration changes are handled for you, so you don't need to worry about onDestroy if the Activity is not finishing.

Views

Views are the Elements that are displayed in Activities.
They are divided into Views and Viewgroups, which can themselves contain Views or Viewgroups.
That results in a hierarchy of Elements, with one at the top.
The Viewgroups are Layouts that position the contained Views according to your configuration.

The most used Layout is LinearLayout. It simply displays Views in a horizontal or vertical list, giving each Element the same space by default.
TextViews can display text.
EditText can get text input from the user.
Buttons can be clicked.
ImageViews can display images.

With these fundamentals you can go ahead and use this plugin. If you need more sophisticated Views or Layouts look into Protocol.md for what's available.

More Repositories

1

termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
Java
34,406
star
2

termux-packages

A package build system for Termux.
Shell
12,914
star
3

termux-api

Termux add-on app which exposes device functionality as API to command line programs.
Java
2,204
star
4

termux-x11

Termux X11 add-on application.
C
1,412
star
5

proot-distro

An utility for managing installations of the Linux distributions in Termux.
Shell
1,403
star
6

termux-styling

Termux add-on app for customizing the terminal font and color theme.
Kotlin
1,142
star
7

termux-api-package

Termux package containing scripts to call functionality in Termux:API.
Shell
1,015
star
8

termux-root-packages

Termux packages that are only usable by root users.
Shell
1,012
star
9

termux-widget

Termux add-on app which adds shortcuts to commands on the home screen.
Java
923
star
10

termux-tasker

Termux add-on app for integration with Tasker.
Java
850
star
11

termux-boot

Termux add-on app allowing programs to be run at boot.
Java
800
star
12

proot

An chroot-like implementation using ptrace.
C
747
star
13

termux.github.io

The main termux site and help pages.
HTML
746
star
14

x11-packages

A set of packages using X11 Windows System.
Shell
535
star
15

termux-docker

Termux environment packaged as Docker image.
Dockerfile
435
star
16

termux-float

Termux add-on app to show the terminal in a floating terminal window.
Java
414
star
17

termux-create-package

Python script to create Termux packages easily.
Python
388
star
18

game-packages

Games for Termux
Shell
308
star
19

termux-services

Scripts to handle services in termux.
Shell
293
star
20

termux-apt-repo

Script to create Termux apt repositories.
Python
286
star
21

termux-tools

Scripts and small programs that are packaged into termux's termux-tools package
Shell
210
star
22

science-packages

Science packages for Termux
C
207
star
23

termux-elf-cleaner

Utility to remove unused ELF sections causing warnings.
C
200
star
24

termux-exec

A execve() wrapper to fix problem with shebangs.
C
161
star
25

command-not-found

Utility for suggesting packages in case typed command was not found.
C++
157
star
26

play-audio

Command-line tool to play audio using OpenSL ES.
C++
122
star
27

termux-auth

Password authentication utilities for Termux.
C
116
star
28

libandroid-shmem

System V shared memory emulation on Android using ashmem.
C
114
star
29

TermuxAm

Android Oreo-compatible am command reimplementation.
Java
98
star
30

termux-packaging

Termux packaging tools.
Rust
90
star
31

repology-metadata

Scripts and Github Actions workflow for generating Repology metadata.
Shell
77
star
32

termux-language-server

🛠️ A language server for some specific bash scripts
Python
73
star
33

termux-root-packages-21-bin

termux-root-packages debs for android 5 and 6. Archived from Bintray repository.
53
star
34

termux-failsafe

An app providing a way to launch failsafe sessions.
Kotlin
47
star
35

wcwidth

A Unicode 15-conformant implementation of wcwidth() in C.
C
40
star
36

termux.com

Sync for termux.github.io/termux.dev at termux.com
39
star
37

libandroid-support

C
32
star
38

termux-am-socket

Faster termux-am implementation that connects to a receiver in termux-app using a unix socket
Shell
32
star
39

science-packages-21-bin

science-package debs for android 5 and 6. Archived from Bintray repository.
25
star
40

getconf

A simple standalone getconf(1) implementation.
C
25
star
41

game-packages-21-bin

game-package debs for android 5 and 6. Archived from Bintray repository.
24
star
42

whatprovides

Utility to find out packages using specific files. Deprecated in favor of apt-file.
Shell
22
star
43

shared-library-testcase

Test case for shared library symbol visibility on dlopen().
C
14
star
44

termux-am-library

Java
14
star
45

distfiles

Moved from https://dl.bintray.com/termux/upstream
11
star
46

create-conventional-changelog

Shell
7
star
47

glibc-packages

Glibc packages for termux (repository mirror)
Shell
7
star
48

termux-community

5
star
49

libandroid-utimes

Library with futimes, futimesat, lutimes from bionic
C
2
star