TEL Launcher for Termux
repository·master·Indexed 41 days ago
https://github.com/t-e-l/telA specialized launcher designed for Termux experts to provide enhanced control and automation capabilities within the Termux environment.
What's inside TEL
- TEL is a launcher designed specifically for Termux experts. It provides a specialized interface or environment for managing and launching tasks within Termux. For detailed usage instructions, architectural concepts, and advanced configuration, users should refer to the official project wiki.
Execute commands from third-party applications via RunCommandService
masterTermux allows third-party Android applications to execute commands or scripts by sending an Intent to the
RunCommandService.Prerequisites
- Enable External Apps: In your Termux environment, you must set
allow-external-appstotruein yourtermux.propertiesfile (located at~/.termux/termux.propertiesor~/.config/termux/termux.properties). - Permission: The calling application must declare the
com.termux.permission.RUN_COMMANDpermission and the user must grant it. - Foreground/Background Behavior:
- On Android 10+, if you want commands started with
RUN_COMMAND_BACKGROUNDset tofalseto automatically bring Termux to the foreground without manual notification interaction, Termux must be granted the 'draw over apps' permission. - To prevent Android from killing the service, it is recommended to disable battery optimizations for Termux.
- On Android 10+, if you want commands started with
Intent Extras
When sending the Intent, use the following keys:
com.termux.RUN_COMMAND_PATH(String, Required): The absolute path to the command or script. Supports$PREFIX/and~/prefixes.com.termux.RUN_COMMAND_ARGUMENTS(String[]): Optional arguments for the command.com.termux.RUN_COMMAND_WORKDIR(String): Optional working directory. Defaults to Termux home. Supports$PREFIX/and~/prefixes.com.termux.RUN_COMMAND_BACKGROUND(Boolean): Whether to run in the background. Defaults tofalse.
// Java example to run 'top -n 5' in Termux home Intent intent = new Intent(); intent.setClassName("com.termux", "com.termux.app.RunCommandService"); intent.setAction("com.termux.RUN_COMMAND"); intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/usr/bin/top"); intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{"-n", "5"}); intent.putExtra("com.termux.RUN_COMMAND_WORKDIR", "/data/data/com.termux/files/home"); intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", false); startService(intent);- Enable External Apps: In your Termux environment, you must set
Run commands via ADB/Shell using am startservice
masterYou can trigger command execution from a shell environment (e.g., via ADB) using the
am startservicecommand. This is useful for automation scripts interacting with the Termux service.Command Syntax
am startservice --user 0 -n com.termux/com.termux.app.RunCommandService \ -a com.termux.RUN_COMMAND \ --es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/top' \ --esa com.termux.RUN_COMMAND_ARGUMENTS '-n,5' \ --es com.termux.RUN_COMMAND_WORKDIR '/data/data/com.termux/files/home' \ --ez com.termux.RUN_COMMAND_BACKGROUND 'false'Argument Mapping
--esais used for the String arraycom.termux.RUN_COMMAND_ARGUMENTS(comma-separated values).--esis used for String extras (PATH,WORKDIR).--ezis used for the Boolean extra (BACKGROUND).
Execute commands via TermuxService Intent actions
masterYou can interact with the
TermuxServiceusing Android Intents. This allows external applications or system components to trigger specific actions within the Termux environment.Execute a command or session
Use the
com.termux.service_executeaction to launch a new terminal session or a background task.- To launch a foreground session: Provide the executable path as the Intent data (URI). The service will create a new
TerminalSessionand launchTermuxActivityto display it. - To run in the background: Set the
com.termux.execute.backgroundextra totrue. This creates aBackgroundJobinstead of a visible session.
Available Intent Extras
Extra Key Type Description com.termux.execute.argumentsString[]Arguments to pass to the executable. com.termux.execute.cwdStringThe current working directory for the execution. com.termux.execute.backgroundbooleanIf true, runs the command as a background task.Service Actions
Action String Purpose com.termux.service_executeLaunches a session or background job. com.termux.service_wake_lockAcquires a partial wake lock and a high-performance WiFi lock. com.termux.service_wake_unlockReleases both the wake lock and the WiFi lock. com.termux.service_stopFinishes all running terminal sessions and stops the service. // Example: Launching a background task via Intent Intent intent = new Intent("com.termux.service_execute"); intent.setData(Uri.parse("/data/data/com.termux/files/usr/bin/top")); intent.putExtra("com.termux.execute.arguments", new String[]{"-b"}); intent.putExtra("com.termux.execute.background", true); context.startService(intent);- To launch a foreground session: Provide the executable path as the Intent data (URI). The service will create a new
Reference: Termux Service Intent Actions
masterThe following action strings are used to control the
TermuxServicelifecycle and power management viastartService(Intent).private static final String ACTION_STOP_SERVICE = "com.termux.service_stop"; private static final String ACTION_LOCK_WAKE = "com.termux.service_wake_lock"; private static final String ACTION_UNLOCK_WAKE = "com.termux.service_wake_unlock"; public static final String ACTION_EXECUTE = "com.termux.service_execute";Reference: RunCommandService Intent Extras
masterThe following constants define the Intent extras used by
com.termux.app.RunCommandServiceto configure command execution.public static final String RUN_COMMAND_ACTION = "com.termux.RUN_COMMAND"; public static final String RUN_COMMAND_PATH = "com.termux.RUN_COMMAND_PATH"; public static final String RUN_COMMAND_ARGUMENTS = "com.termux.RUN_COMMAND_ARGUMENTS"; public static final String RUN_COMMAND_WORKDIR = "com.termux.RUN_COMMAND_WORKDIR"; public static final String RUN_COMMAND_BACKGROUND = "com.termux.RUN_COMMAND_BACKGROUND";Reference: Termux Service Intent Extras
masterThe following extra keys are used with the
com.termux.service_executeaction to configure the execution environment.public static final String EXTRA_ARGUMENTS = "com.termux.execute.arguments"; public static final String EXTRA_CURRENT_WORKING_DIRECTORY = "com.termux.execute.cwd"; public static final String EXTRA_EXECUTE_IN_BACKGROUND = "com.termux.execute.background";Reference: Termux File System Paths
masterThese constants define the primary directory structure used by Termux. Note that
FILES_PATHis a symlink on Android M preview.public static final String FILES_PATH = "/data/data/com.termux/files"; public static final String PREFIX_PATH = FILES_PATH + "/usr"; public static final String HOME_PATH = FILES_PATH + "/home";