Giter Site home page Giter Site logo

termux-tasker's Introduction

Termux:Tasker

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

A Termux plugin app allowing Termux commands to be executed from Tasker and other plugin host apps.

Contents

Installation

Latest version is v0.6.0.

Check termux-app Installation for details before reading forward.

F-Droid

Termux:Tasker application can be obtained from F-Droid from here.

You do not need to download the F-Droid app (via the Download F-Droid link) to install Termux:Tasker. You can download the Termux:Tasker APK directly from the site by clicking the Download APK link at the bottom of each version section.

It usually takes a few days (or even a week or more) for updates to be available on F-Droid once an update has been released on Github. The F-Droid releases are built and published by F-Droid once they detect a new Github release. The Termux maintainers do not have any control over the building and publishing of the Termux apps on F-Droid. Moreover, the Termux maintainers also do not have access to the APK signing keys of F-Droid releases, so we cannot release an APK ourselves on Github that would be compatible with F-Droid releases.

The F-Droid app often may not notify you of updates and you will manually have to do a pull down swipe action in the Updates tab of the app for it to check updates. Make sure battery optimizations are disabled for the app, check https://dontkillmyapp.com/ for details on how to do that.

Github

Termux:Tasker application can be obtained on Github either from Github Releases for version >= 0.6.0 or from Github Build action workflows.

The APKs for Github Releases will be listed under Assets drop-down of a release. These are automatically attached when a new version is released.

The APKs for Github Build action workflows will be listed under Artifacts section of a workflow run. These are created for each commit/push done to the repository and can be used by users who don't want to wait for releases and want to try out the latest features immediately or want to test their pull requests. Note that for action workflows, you need to be logged into a Github account for the Artifacts links to be enabled/clickable. If you are using the Github app, then make sure to open workflow link in a browser like Chrome or Firefox that has your Github account logged in since the in-app browser may not be logged in.

The APKs for both of these are debuggable and are compatible with each other but they are not compatible with other sources.

Google Play Store (Deprecated)

Termux and its plugins are no longer updated on Google Play Store due to android 10 issues and have been deprecated. It is highly recommended to not install Termux apps from Play Store any more. Check https://github.com/termux/termux-app#google-play-store-deprecated for details.

Setup Instructions

Install Termux app (Mandatory)

The Termux:Tasker plugin requires Termux app to run the actual commands. You need to install it and start it at least once and have it install the bootstrap files for the plugin to start working. The Termux prefix directory /data/data/com.termux/files/usr/ and Termux home directory /data/data/com.termux/files/home/ must also exist and must have read, write and execute permissions (0700) for the plugin to work. The $PREFIX/ is shortcut for the Termux prefix directory and can also be referred by the $PREFIX shell environment variable. The ~/ is a shortcut for the Termux home directory and can also be referred by the $HOME shell environment variable. Note that ~/ will not expand inside single or double quotes when running commands. Permissions and ownerships can be checked with the stat <path> command.

com.termux.permission.RUN_COMMAND permission (Mandatory)

For Termux:Tasker version >= 0.5, the plugin host app will need to be granted the com.termux.permission.RUN_COMMAND permission to run ANY plugin commands. This is a security measure to prevent any other apps from running commands in Termux context which do not have the required permission granted to them. This is also required for the RUN_COMMAND Intent.

The Tasker app has requested the permission since v5.9.3, so you will need to update the app if you are using an older version. You can grant the permission using the Permissions activity in the App Info activity of your plugin host app. For Tasker you can grant it with: Android Settings -> Apps -> Tasker -> Permissions -> Additional permissions -> Run commands in Termux environment.

If you do not grant the permission, you will likely get errors like receiver com.termux.tasker.FireReceiver requires permission com.termux.permission.RUN_COMMAND which we don't have when running the Termux:Tasker plugin action in Tasker. Note that, the %errmsg for missing permissions will not be set if you are using Tasker version < 5.11.1.beta and Continue Task After Error is enabled, only %err will be set to 1. You can open the plugin configuration screen to detect missing permissions of the plugin host.

~/.termux/tasker/ Directory (Optional)

The ~/.termux/tasker/ directory stores the scripts that can be run with the plugin without setting allow-external-apps property to true if you do not want to use absolute paths. Open a non-root termux session and run the below command to create it and give it read, write and executable permissions (0700). The tasker directory must have read permission, otherwise the plugin will not be able to read the script files and give errors like No regular file found at path for any script name entered in the Executable field of plugin configuration. The tasker directory of the script must also have executable permissions for the script to be allowed to execute.

mkdir -p /data/data/com.termux/files/home/.termux/tasker
chmod 700 -R /data/data/com.termux/files/home/.termux

allow-external-apps property (Optional)

Termux:Tasker version >= 0.5 also allows commands to be run outside the ~/.termux/tasker/ directory by setting absolute paths in the Executable field of the plugin configuration ONLY if allow-external-apps property is set to true in ~/.termux/termux.properties file. This is an added security measure. DO NOT set it to true if you have given a relatively untrusted app com.termux.permission.RUN_COMMAND permission, since it will be able to run arbitrary commands in termux or even root context (assuming termux has been granted root permissions) in the background without user intervention. The ~/.termux directory must have read permission, otherwise the plugin will not be able to read the property values. This is also required for the RUN_COMMAND Intent intent.

  • Automatic You can use the one-liner commands below to set the desired value. The commands will append the desired value using echo command to the file if the file doesn't exist or the property doesn't exist in the file, otherwise it will sed replace any existing values of the key with the desired value.

    To set allow-external-apps property to true.

    value="true"; key="allow-external-apps"; file="/data/data/com.termux/files/home/.termux/termux.properties"; mkdir -p "$(dirname "$file")"; chmod 700 "$(dirname "$file")"; if ! grep -E '^'"$key"'=.*' $file &>/dev/null; then [[ -s "$file" && ! -z "$(tail -c 1 "$file")" ]] && newline=$'\n' || newline=""; echo "$newline$key=$value" >> "$file"; else sed -i'' -E 's/^'"$key"'=.*/'"$key=$value"'/' $file; fi
    

    To set allow-external-apps property to false.

    value="false"; key="allow-external-apps"; file="/data/data/com.termux/files/home/.termux/termux.properties"; mkdir -p "$(dirname "$file")"; chmod 700 "$(dirname "$file")"; if ! grep -E '^'"$key"'=.*' $file &>/dev/null; then [[ -s "$file" && ! -z "$(tail -c 1 "$file")" ]] && newline=$'\n' || newline=""; echo "$newline$key=$value" >> "$file"; else sed -i'' -E 's/^'"$key"'=.*/'"$key=$value"'/' $file; fi
    
  • Manual You can do it manually by running the below commands to open the nano text editor in the terminal. Then add/update a line allow-external-apps=true to set the property to true, and press Ctrl+o and then Enter to save and Ctrl+x to exit.

    file="/data/data/com.termux/files/home/.termux/termux.properties";
    mkdir -p "$(dirname "$file")";
    nano "$file"

Draw Over Apps permission (Optional)

For android >= 10 there are new restrictions that prevent activities from starting from the background. This prevents the background TermuxService from starting a terminal session in the foreground and running the commands until the user manually clicks Termux notification in the status bar dropdown notifications list. This only affects plugin commands that are to be executed in a terminal session and not the background ones. Termux version >= 0.100 requests the Draw Over Apps permission so that users can bypass this restriction so that commands can automatically start running without user intervention. You can grant Termux the Draw Over Apps permission from its App Info activity Android Settings -> Apps -> Termux -> Advanced -> Draw over other apps.

Usage

Tasker

  1. Create a new Action in a Task.
  2. In the resulting Select Action Category dialog, select Plugin.
  3. In the resulting Action Plugin dialog, select Termux:Tasker.
  4. Click the edit button to edit the configuration.
  5. Run the task once the configuration is complete.

Plugin Configuration

The plugin configuration activity can be started by plugin host apps to configure the plugin to define what commands should be run and in which mode.

The text fields support plugin host app local variables (all lowercase) like %executable, %arguments, %workdir, %stdin, etc and you may use multiple variables in a single field.

Executable

The Executable text field defines the executable that needs to be run. It can either be set to a file in ~/.termux/tasker/ directory or to an absolute path if allow-external-apps property is set to true (check Setup Instructions). Absolute paths can be like /data/data/com.termux/files/usr/bin/bash. The $PREFIX/ and ~/ prefixes are also supported, like $PREFIX/bin/bash or ~/some-script.

Execute permissions will automatically be set for the executable file if it exists inside the ~/.termux/tasker/ directory when the plugin action is run. It is the user's responsibility to set read and execute permissions for the executable file if it exists outside the ~/.termux/tasker/ directory. That can be done by running the command chmod 700 "/path/to/executable" from a terminal session before running the plugin action.

Arguments

The Arguments text field defines the argument that will be passed to the executable. For Termux:Tasker version >= 0.5, arguments will be processed just like there are if commands are run in a shell like bourne shell. It uses ArgumentTokenizer to parse the arguments string.

Arguemnts are split on whitespaces unless quoted with single or double quotes. Double quotes and backslashes can be escaped with backslashes in arguments surrounded with double quotes.

Any argument surrounded with single quotes is considered a literal string. However, if an argument itself contains single quotes, then they will need to be escaped properly. You can escape them by replacing all single quotes ' in an argument value with '\'' before passing the argument surrounded with single quotes. So an argument surrounded with single quotes that would have been passed like 'some arg with single quote ' in it' will be passed as 'some arg with single quote '\'' in it'. This is basically 3 parts 'some arg with single quote ', \' and ' in it' but when processed, it will be considered as one single argument with the value some arg with single quote ' in it that is passed to the executable.

For Tasker, you can use the Variable Search Replace action on an %argument variable to escape the single quotes. Set the Search field to one single quote ', and enable Replace Matches toggle, and set Replace With field to one single quote, followed by two backslashes, followed by two single quotes '\\''. The double backslash is to escape the backslash character itself.

Working directory path

The Working directory path text field for Termux:Tasker version >= 0.5 defines the working directory that should be used while running the command. The directory must be readable by the termux app. It is the user's responsibility to create the directory if its outside the ~/ directory for version < 0.6.0 and /data/data/com.termux/files directory for version >= 0.6.0. That can be done by running the command mkdir -p "/path/to/workdir" from a terminal session before running the plugin action. The $PREFIX/ and ~/ prefixes are also supported, like $PREFIX/some-directory or ~/some-directory.

Stdin

The Stdin text field for Termux:Tasker version >= 0.6.0 can be used to pass scripts via standard input (stdin), like a bash script to the $PREFIX/bin/bash shell and a python script to the $PREFIX/bin/python shell or any other commands. This allows scripts to be defined in the plugin host app instead of defining physical script files in ~/.termux/tasker/ directory. Check Defining Scripts In Plugin Host App for details.

Note that if passing script via stdin, do not pass arguments, since it will fail depending on shell, at least will for bash.

The max supported length of a script is 45K characters taking into consideration the Tasker plugin bundle limits of 100KB when its stored in a Parcel. On Android 7-11, the String characters are stored in Parcel as UTF-16, i.e 2 bytes. So we use 10KB for rest of the plugin configuration data and half of the remaining (90KB) for storing the script.

Terminal Session Action

The Terminal Session Action text field for Termux:Tasker version >= 0.6.0 defines what should happen when a foreground session command is received for the Termux. The user can define whether the new session should be automatically switched to or if existing session should remain as the current session. The user can also define if foreground session commands should open the TermuxActivity or if they should run in the "background" in the Termux notification. The user can click the notification to open the sessions. The valid values are defined by TermuxConstants.TERMUX_APP.TERMUX_SERVICE.VALUE_EXTRA_SESSION_ACTION_*, currently, between 0 and 3.

Custom Log Level

The Custom Log Level text field for Termux:Tasker version >= 0.6.0 defines the log level for background commands that should be used by Termux.

By default Termux only logs command stdout and stderr to logcat if user has set log level to VERBOSE in Termux app settings (not Termux:Tasker). However, if command outputted too much data to logcat, then logcat clients like in Android Studio would crash.

So one can pass a custom log level that is >= to the log level set it Termux app settings where (OFF=0, NORMAL=1, DEBUG=2, VERBOSE=3) for custom behaviour. If you pass 0, it will completely disable logging. If you pass 1, logging will only be enabled if log level in termux settings is NORMAL or higher. If custom log level is not passed, then default behaviour will remain and log level in Termux app settings must be VERBOSE or higher for logging to be enabled. Note that the log entries will still be logged with priority Log.VERBOSE regardless of log level, i.e logcat will have V/.

The entries logcat component will be TermuxCommand. For output at stdout, the entry format is [<pid>-stdout] ... and for the output at stderr, the entry format is [<pid>-stderr] .... The <pid> will be the process id (pid) as an integer that was started by Termux for the executable. For example: V/TermuxCommand: [66666-stdout] ....

Using Custom Log Level to send commands to Tasker

Instead of using am command to send messages back to Tasker, you can use Tasker Logcat Entry profile event to listen to messages from Termux at both stdout and stderr. This might be faster than am command intent systems or at least possibly more convenient in some use cases.

So setup a profile with the Component value set to TermuxCommand and Filter value set to -E 'TermuxCommand: \[[0-9]+-((stdout)|(stderr))\] message_tag: .*' and enable the Grep Filter toggle so that entry matching is done in native code. Check Tasker Logcat Info documentation for details. Also enable Enforce Task Order in profile settings and set collision handling to Run Both Together so that if two or more entries are sent quickly, entry task is run for all. Tasker currently (v5.13.16) is not maintaining order of entry tasks despite the setting.

Then start a Termux:Tasker plugin action with custom log level 1 (assuming current log level is NORMAL) and you should be able to receive the entries for whatever you send to stdout and stderr in your script that starts with message_tag: as %lc_text in entry task of tasker Logcat Entry profile. You can remove the prefix from the %lc_text variable with Variable Search Replace action. Set the Search field to TermuxCommand: \[[0-9]+-((stdout)|(stderr))\] message_tag: , and enable Replace Matches toggle, and leave Replace With empty.

Execute in a terminal session

The Execute in a terminal session toggle defines whether the commands will be run in the background or in a foreground terminal session.

If the toggle is enabled, a new terminal session will open up automatically in the foreground and commands will be run inside it. Result of commands is not returned to the plugin host app for version < 0.6.0. For version >= 0.6.0, result will be returned in %stdout and %result variables. The %stdout variable will only contain the session transcript and will contain both stdout and stderr combined, basically anything sent to the the pseudo terminal /dev/pts, including PS1 prefixes for interactive sessions. For foreground commands that exited with failure will require Termux app version >= 0.118.0 for sessions to automatically close without waiting for user to press enter.

If the toggle is not enabled, then commands are run in the background and result of commands is returned to the plugin host app in %stdout, %stderr and %result variables.

Check Setup Instructions for android >= 10 restrictions that will prevent the commands from automatically starting unless notification is clicked.

Wait for result for commands

The Wait for result for commands toggle for Termux:Tasker version >= 0.6.0 defines whether the plugin action should wait for result of commands. It will apply to both foreground session and background commands. Check Plugin Variables for details.

Check Templates section for templates that can be used for various configurations.

Plugin Variables

Depending on plugin configuration, the following variables may be returned.

  • %stdout containing stdout of commands.
  • %stdout_original_length containing original length of stdout.
  • %stderr containing stderr of commands.
  • %stderr_original_length containing original length of stderr.
  • %result containing exit code of commands. The exit code 0 often means success and anything else is usually a failure of some sort.
  • %err containing exit code of plugin action. This will be set only if running the action itself failed like missing permissions or invalid configuration. This may be set by the plugin host app or the plugin. This will not be set if plugin action succeeded.
  • %errmsg containing the error message of why the plugin action failed if %err is set.  

If the timeout value of the plugin action is set to 0 or None (slider to extreme left in Tasker), then no variables will be returned, regardless of whether commands need to be run in a foreground terminal session or in background. Even %errmsg will not be set to notify of any errors while running the plugin action since plugin host app will not wait for the plugin to return any variables. This is important for cases like if allow-external-apps is not set to true but an absolute path outside ~/.termux/tasker/ directory is set as the Executable, in which case the plugin action will appear to have succeeded but no commands will execute.

If the timeout value of the plugin action is set to >0 and Wait for result for commands toggle is enabled, then the result of commands will be returned in %stdout, %stderr (only background) and %result variables. The %err and %errmsg variables may also be set if the action failed. Note that if the timeout has passed by the time commands finish, the result of command variables will not be set in the plugin host app task and the action will exit with a timeout error, the %err variable will be set to 2 and %errmsg to timeout, at least in Tasker.

If the timeout value of the plugin action is set to >0 and Wait for result for commands toggle is not enabled, then %stdout, %stderr and %result variables will not be returned. Only the %err and %errmsgvariables may be set if the action failed.

The (new) default timeout is set to 10s for all configurations. If you are running background commands that will likely take longer to run, then increase the timeout or set it to Never (slider to extreme right in Tasker). The plugin host app may still get killed by android if it keeps running for long time regardless of timeout value, check here for more info. Even if the commands are to be run in a foreground terminal session, do not set timeout to 0 but use 10s instead, since with timeout 0, plugin host app will not wait for any errors to be returned by the plugin in %err and %errmsg variables and continue the task and the user wouldn't know if any error occurred. Users who already have preexisting actions with the timeout set to 0, like for foreground terminal session commands (considering previous default was 0) should update their tasks and use the new default 10s instead, just opening the configuration screen and returning should automatically do it.  

For Termux:Tasker version >= 0.5, the %errmsg, %stdout, %stderr and %result variables will also be automatically cleared whenever the action is run if timeout is greater than 0 to solve the issue of if multiple actions are run in the same task, then variables from previous action may still be set and get mixed in with current ones. For older versions, you can use a Variable Clear action in Tasker with Pattern Matching enabled and the Name field set to %errmsg/%stdout/%stderr/%result to clear all of them before each plugin action if multiple actions are run in a task or Local Variable Passthrough is enabled in Tasker.

The %err and %errmsg variables will mainly only be set for Termux:Tasker version >= 0.5. These will be set if there are errors like if an executable file is not found, or if allow-external-apps property is not set to true but an absolute path is specified as the executable. Tasker itself may set it too like if Tasker has not been granted the com.termux.permission.RUN_COMMAND permission when running the plugin action or if a timeout occurs, etc.

The %err and %errmsg variables must be stored in another variable with the Variable Set action right after the plugin action if they have to be checked and used later. The plugin host app like Tasker sets and clears %err for each action and it is only available in the next action. To check if and what they are set to, add a Variable Clear action for %command_failed variable before the plugin action, then add a Variable Set action after the plugin action for the %command_failed variable with the value %err %errmsg and If conditions If %err Set OR If %errmsg Set. Then you can just check If %command_failed Set afterward and flash it to notify the user or exit the task if necessary. Error checking should ideally also be done based on %result and optionally the %stderr variables before continuing the task.  

The %stdout_original_length and %stderr_original_length can be used to check if %stdout and %stderr were truncated by Termux app before sending them back to plugin host app in case they were too large and would have triggered TransactionTooLargeException. The stdout and stderr sent back will be truncated from the start to max 100KB combined. The errmsg will also be truncated from end to max 25KB. Check here and here for details.

Check Templates section for templates on how error and result variables should be handled for various configurations.

Templates

The templates were written for version < 0.6.0 and currently have not been updated for version >= 0.6.0.

Tasker

  • Tasks

    • XML Download the Termux Tasker Plugin Basic Templates Task XML file to the android download directory. To download, right-click or hold the Raw button at the top after opening a file link and select Download/Save link or use curl from a termux shell. Then import the downloaded task file into Tasker by long pressing the Task tab button in Tasker home and selecting Import Task.

      curl -L 'https://github.com/termux/termux-tasker/raw/master/templates/plugin_hosts/tasker/Termux_Tasker_Plugin_Basic_Templates.tsk.xml' -o "/storage/emulated/0/Download/Termux_Tasker_Plugin_Basic_Templates.tsk.xml"

    • Taskernet Import Termux Tasker Plugin Basic Templates Task from Taskernet from here.

    Check Termux Tasker Plugin Basic Templates Task Info file for more info on the task.

  • Scripts To use the above task, you will also need to place the termux_tasker_basic_bash_test and termux_tasker_basic_python_test scripts in ~/.termux/tasker/ directory after following its Setup Instructions. They basically just print the first 2 args to stdout if only 2 args are received, otherwise exit with error.

    1. Download the script files.

      • Download to ~/.termux/tasker/ directly from github using curl using a non-root termux shell.

        curl -L 'https://github.com/termux/termux-tasker/raw/master/templates/scripts/termux_tasker_basic_bash_test' -o "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_bash_test"

        curl -L 'https://github.com/termux/termux-tasker/raw/master/templates/scripts/termux_tasker_basic_python_test' -o "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_python_test"

      • Download them manually to android download directory and then use cat to copy them to ~/.termux/tasker/ or manually do it with a SAF file browser.

        cat "/storage/emulated/0/Download/termux_tasker_basic_bash_test" > "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_bash_test"

        cat "/storage/emulated/0/Download/termux_tasker_basic_python_test" > "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_python_test"

    2. Set executable permissions.

      chmod 700 "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_bash_test"

      chmod 700 "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_python_test"

    To modify the scripts you can use nano.

    nano "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_bash_test"
    nano "/data/data/com.termux/files/home/.termux/tasker/termux_tasker_basic_python_test"

Termux needs to be granted Storage permission to allow it to access /storage/emulated/0/Download directory, otherwise you will get permission denied errors while running commands.

Creating And Modifying Scripts

You can create scripts in ~/.termux/tasker/ directory after following its Setup Instructions. Scripts can also be created elsewhere in Termux files directory but will require allow-external-apps to be set to true for the plugin to access them.

You can use shell based text editors like nano, vim or emacs to create and modify scripts.

nano ~/.termux/tasker/some_script

You can also use GUI based text editor android apps that support SAF. Termux provides a Storage Access Framework (SAF) file provider to allow other apps to access its ~/ home directory. However, the $PREFIX/ directory is not accessible to other apps. The QuickEdit or QuickEdit Pro app does support SAF and can handle large files without crashing, however, it is closed source and its pro version without ads is paid. You can also use Acode editor or Turbo Editor if you want an open source app.

Note that the android default SAF Document file picker may not support hidden file or directories like ~/.termux which start with a dot ., so if you try to use it to open files for a text editor app, then that directory will not show. You can instead create a symlink for ~/.termux at ~/termux_sym so that it is shown. Use ln -s "/data/data/com.termux/files/home/.termux" "/data/data/com.termux/files/home/termux_sym" to create it.

Debugging

You can help debug problems like how arguments are being parsed by the plugin or if the plugin is even firing etc by setting appropriate logcat Log Level in options menu (3 dots) in the plugin configuration screen or in Termux app settings -> Termux:Tasker -> Debugging -> Log Level (Requires Termux app version >= 0.113). Note that whatever log level is set will affect the entire plugin app and all plugin actions and not just for the action whose configuration you used to set it. The setting only exists inside the configuration activity of actions because creating a separate launcher activity that would be shown in the list of apps in the launcher just for this setting doesn't seem worth it. The Log Level defaults to Normal and log level Verbose currently logs additional information. Its best to revert log level to Normal after you have finished debugging since private data may otherwise be passed to logcat during normal operation and moreover, additional logging increases execution time.

The plugin does not execute the commands itself but sends an execution intent to Termux app, which has its own log level which can be set in Termux app settings -> Termux -> Debugging -> Log Level. So you must set log level for both Termux and Termux:Tasker app settings to get all the info.

Once log levels have been set, you can run the logcat command in Termux app terminal to view the logs in realtime (Ctrl+c to stop) or use logcat -d > logcat.txt to take a dump of the log. You can also view the logs from a PC over ADB. For more information, check official android logcat guide here.

Log Levels
  • Off - Log nothing.
  • Normal - Start logging error, warn and info messages and stacktraces.
  • Debug - Start logging debug messages.
  • Verbose - Start logging verbose messages.

Worthy Of Note

Arguments and Result Data Limits

There are limits on the arguments size you can pass to commands or the full command string length that can be run, which is likely equal to 131072 bytes or 128KB for an android device defined by ARG_MAX but after subtracting shell environment size, etc, it will roughly be around 120-125KB but limits may vary for different android versions and kernels. You can check the limits for a given termux session by running true | xargs --show-limits. If you exceed the limit, you will get exceptions like Argument list too long. You can manually cross the limit by running something like $PREFIX/bin/echo "$(head -c 131072 < /dev/zero | tr '\0' 'a')" | tr -d 'a', use full path of echo, otherwise the echo shell built-in will be called to which the limit does not apply since exec is not done.

Moreover, exchanging data between Tasker and Termux:Tasker is done using Intents, like sending the command and receiving result of commands in %stdout and %stderr. However, android has limits on the size of actual data that can be sent through intents, it is roughly 500KB on android 7 but may be different for different android versions. The Termux app based on testing still sets a safe limit at 100KB and will truncate any data higher than that. Check %stdout_original_length and %stderr_original_length in Plugin Variables section for details.

Basically, make sure any data/arguments you send to Termux:Tasker is less than 120KB (or whatever you found) and any expected result sent back is less than 100KB, but best keep it as low as possible for greater portability. If you want to exchange an even larger data between tasker and termux, use physical files instead.

The argument data limits also apply for the RUN_COMMAND Intent.

Termux Environment

Termux does not load the environment fully for external plugins or RUN_COMMAND Intent commands, like setting LD_PRELOAD, so any external scripts which do not have shebangs to full path to termux bin directory will not work if called from inside your plugin scripts, since libtermux-exec.so is not called since LD_PRELOAD isn't set and you will get bad interpreter: No such file or directory errors. Simply setting LD_PRELOAD will not work either without starting a new shell. So make sure to set the shebangs correctly for any external scripts you want to run from inside your plugin script. The correct shebangs for termux scripts are like #!/data/data/com.termux/files/usr/bin/bash for bash scripts instead of #!/usr/bin/bash used in common linux distros. You can also use termux-fix-shebang command on the external scripts before running them with the plugin to fix the shebangs automatically or use tudo/sudo mentioned below.

Defining Scripts In Plugin Host App

Any script files that need to be run need to be created in ~/.termux/tasker/ directory. It may get inconvenient to create physical script files for each type of command you want to run. These script files are also neither part of backups of plugin host apps like Tasker and require separate backup methods and nor are part of project configs shared with other people or even between your own devices, and so the scripts need to be added manually to the ~/.termux/tasker/ directory on each device.

To solve such issues and to dynamically define scripts of different interpreted languages inside your plugin host app like Tasker and to pass them to Termux as arguments instead of creating script files, you can either use Stdin plugin configuration field or use tudo or sudo.

The tudo script can be used for running commands in termux user context and the sudo script for running commands with super user (root) context, check their script command type. These scripts will also load the termux environment properly like setting LD_PRELOAD etc before running the commands. There are much more customizable then using Stdin and support things that aren't possible to be provided via the plugin.

For Maintainers and Contributors

Check For Maintainers and Contributors section of termux/termux-app README for details.

Forking

Check Forking section of termux/termux-app README for details.

termux-tasker's People

Contributors

adamjhogan avatar agnostic-apollo avatar archenoth avatar dependabot[bot] avatar fixato avatar fornwall avatar giorgosxou avatar grimler91 avatar landfillbaby avatar tacothedank avatar thenothingman 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

termux-tasker's Issues

Inline script support?

I have just used termux-tasker plugin recently and I could not find options where I can set termux to execute script inline. There is only option to create file on sdcard and set path to the plugin. Most of the time, I want everything is inside tasker so it's much easier to back up and manage. If there are multiple tasks, I may need to create multiple file for termux which is hard to manage when time passed. If we could execute script inline and output is return to specific variable name it would be great.

Termux Task not working

Termux:Task isn't working for me for some reason...the task gets executed but script never runs
the script is in "~/.termux/tasker" folder, I have tried with both "Execute in a terminal session" checked and unchecked and simply nothing happens, it doesn't even show a blank terminal window
Tasker Run log here http://paste.ubuntu.com/23863288/
I have installed Termux and all it's plugin's from f-droid
Termux version : 0.46
Termux:Task version : 0.1
Android version : 5.1.1 lollipop
Device : VivoV3Max
ty

Tasker variables in the arguments field?

Is it possible to put Tasker variables into the arguments field?

It would cut out so many steps; To get around it, I first write the variables to a file, then have a script parse the data from said file and then finally run the intended script with the actual arguments I needed.

Just plopping a buncha %VARs into the Termux:Task argument field would make life somuch easier.

termux-services cant be called via termux-tasker

Problem description
When I use termux services to start or stop a service i.e. sv up httpd it works fine in termux but in termux-tasker it errors 'unable to change to service directory'

I call this via a simple one line script in /termux/taskser. Works in termux directly

I am sure it must be something I am doing, maybe working directory? but I cant figure it out, could be permissions?

I've tried running in tasker directly with tasker function, having set termux properties to allow external. Same issue

Steps to reproduce

Expected behavior
Calling termux-services should work from tasker the same as directly in termux

Additional information

  • Termux application version: 0.118.0
  • Android OS version: 12
  • Device model: s22 ultra

After rebooting the phone, Termux: Tasker settings are returned to Battery saver.

The add-on does not work in the background. constantly have to restore the "Background settings" in "No restrictions". After reboot, "Background settings" automatically switches to "Battery saver"

Problem description

Steps to reproduce

Expected behavior

Additional information

  • Termux application version: 0.4
  • Android OS version: 7.0 MIUI Global 10.2
  • Device model:Redmi Note 4

configurable stdout size

As a user I use a lot of commands in which list many many values, and I need to pass them on for processing, as Termux Tasker cannot execute multiple commands via pipe char I need to pass the data via %stdout, the problem is it is limited to very small size, I have a list of more than 10k items and only about 3199 is within the %stdout when the variable is available in Tasker. While I understand that keeping the var size is for my own good, I would like a way to configure it so it will serve my purposes perhaps via the termux.properties file?

Not able to run scripts from termux tasker plugin

I created the /data/data/com.termux/files/home/.termux/tasker folder and placed a shell script in it
I can run scripts same from directory but not from my termux tasker plugin

from termux app

$ sh /data/data/com.termux/files/home/.termux/tasker/script1.sh

$ sh ./data/data/com.termux/files/home/.termux/tasker/script1.sh

sh: 0: Can't open ./data/data/com.termux/files/home/.termux/tasker/script1.sh

$ bash /data/data/com.termux/files/home/.termux/tasker/script1.sh

$ bash ./data/data/com.termux/files/home/.termux/tasker/script1.sh

bash: ./data/data/com.termux/files/home/.termux/tasker/script1.sh: No such file or directory

$ cd /data/data/com.termux/files/home/.termux/tasker

$ ls

num.py script.sh script1.sh

$ sh script1.sh

num.py script.sh script1.sh
from termux-tasker plugin

exec("/data/data/com.termux/files/home/.termux/tasker/script1.sh"): No such file or directory

Can you please add the 3 Returning Variables: %stdout, %stderr, %err, like the "Run Shell" action has?

Hi

May I suggest to add 3 Returning Variables, that will be filled by the Termux Task plugin, after returning from the execution?

The needed 3 variables are:
%stdout
%stderr
%err (the returning error code from the program that was run)

Please see this screenshot:
https://i.postimg.cc/QdwwXNVX/Screenshot-20190417-144859-resize.png

(the first 2 appear, and the 3rd one does not appear, but Tasker fills it into a variable named %err)

That way we can easily get the Result from the program we ran.

Thank you very much

Timeout Issue with Automate

Problem description
I have an issue using the Termux Tasker plugin with Automate around timeouts. If the Termux command completes in less than 10 seconds it is fine, but if not it fails.

Error log:
01-21 11:30:13.290 I 58@1: Flow beginning 01-21 11:30:13.291 I 58@2: Plug-in action 01-21 11:30:13.368 D 58@2: PlugInSetting ACTION_FIRE_SETTING: resultCode=3 01-21 11:30:13.369 D 58@2: Starting 10000 ms timeout, as requested 01-21 11:30:23.388 F 58@2: java.util.concurrent.TimeoutException: Plug-in didn't respond within requested timeout 01-21 11:30:23.390 I 58@2: Stopped by failure

Steps to reproduce
Create a new Automate flow, add a termux task that takes longer than 10 seconds to execute.

Expected behaviour
The ability to set, or remove the timeout

Additional information

  • Termux application version: 1.22.1
  • Android OS version: 10
  • Device model: Samsung Galaxy S10+

See comments from Automate author here:

https://old.reddit.com/r/AutomateUser/comments/erthy2/automate_termux_timeout_issue/

Tasker says plugin error

Problem description
When i try to select termux tasker plugin from tasker it says plugin error Screenshot_20201212-071916818.jpg

Steps to reproduce
Just select termux tasker plugin from tasker.
Screenshot_20201212-071909596.jpg
Expected behavior
It should work as it was before updating.

Additional information

  • Termux application version: 0.103
  • Android OS version: 10
  • Device model: One plus 7 pro

Allow setting standard input

Feature description

I think it would be useful to be set stdin for the command. This would allow a bit more data to be passed to the command, with less concern about escaping.

executing script from ./ubuntu_directory/ not ".termux/tasker"

i want to first run Ubuntu chroot for Termux by executing this script: ./ubuntu_directory/start-ubuntu.sh and then execute hollywood command

what i did was using VI command creating a script (for example: script1.sh) and in vi editor tried writing ./ubuntu_directory/start-ubuntu.sh and /ubuntu_directory/start-ubuntu.sh and start-ubuntu.sh hoping it run the start-ubuntu.sh script from ./ubuntu_directory/ but didn't work so far, so i am stock and not figured it up how to execute hollywood after that

to sum it up i want to execute "./ubuntu_directory/start-ubuntu.sh" and then "hollywood" and i want to use Termux:Task, all i know is Termux Tasker will run scripts in ".termux/tasker" so maybe there is a way to make a script in .termux/tasker to run script or as shortcut of the start-ubuntu.sh
in ./ubuntu_directory/ ? and then how to execute "hollywood" command? maybe with argument field?! do i make sense?

Session/task remains open after the executable is finished

Problem description
After running an executable from Tasker, the notification with the running session (if run in terminal) or task (if run as a task) remains active indefinitely. Clicking on the exit button does nothing. The only way to dismiss the notification is to open termux-app and exit out of it. Then the zombie session/task is closed and the notification finally disappears.

Steps to reproduce
Run anything with Termux:Tasker from Tasker. Any script, with or without terminal.

Expected behavior
Task finishes, notification disappears.

Additional information
It happened the first time after I upgraded to v0.5. However, downgrading to v0.4 did not solve the problem.

  • Termux application version: v0.105
  • Android OS version: 10
  • Device model: Xiaomi Redmi Note 7

Yeecli non functional from tasker

Problem description
I have Python installed and installed a program that allows me to control my lights but the command does not function when called from tasker. I have every permission allowed for termux, tasker, termux:tasker, etc and everything set correctly in termux.properties as well as ran termux-reload-settings afterwards.
Steps to reproduce

pkg i python
pip install yeecli
echo "allow-external-apps=true" >> ~/.termux/termux.properties
termux-reload-settings

See:
Screenshot_20210331-155005_Termux_Tasker

Expected behavior
The command should run etc my light should toggle.

Additional information

  • Termux application version: 0.108
  • Android OS version: 11 (crDroid)
  • Device model: OnePlus 7 Pro

Can't execute tasks if tasks are within a mount

This is a bit of a weird one, and very specific to a certain kind of setup, so I would understand if this is a wontfix.

Problem description
If your ~/.termux/tasker folder is inside a mount, Termux:Tasker only executes the files that exist in the unmounted state as well.

Steps to reproduce

Setup test scripts 1 2 3

  1. Setup script 1 and 2 inside ~/.termux/tasker normally.
  • script1 prints 1 normal to log
  • script2 prints 2 normal to log
  1. Mount a new folder to ~/.termux
  2. Create another 2 scripts
  • script2 prints 2 mounted to log
    * has the same name as one of the normal scripts
  • script 3 print 3 mounted to log
  1. Run all 3 script with Tasker

Step by step:

$ mkdir -p ~/.termux/tasker 
$ echo "echo 1 normal > ~/log" >> ~/.termux/tasker/script1
$ echo "echo 2 normal > ~/log" >> ~/.termux/tasker/script2
$ chmod +x ~/.termux/tasker/*
$ mkdir ~/test
$ sudo mount --bind ~/test ~/.termux
$ mkdir -p ~/.termux/tasker
$ echo "echo 2 mounted > ~/log" >> ~/.termux/tasker/script2
$ echo "echo 3 mounted > ~/log" >> ~/.termux/tasker/script3
$ chmod +x ~/.termux/tasker/*

Create a test task running script 1 2 and 3

Screenshot_20210512-023647_Tasker_small

Enable Continue Task After Error for all of them.

Run this task.

Check the ~/log file. It shows:

$ cat ~/log
2 mounted
$

Expected behavior
Since at the time of the execution only script2 and script3 are in ~/.termux/tasker, these two should run and produce this logfile:

$ cat ~/log
2 mounted
3 mounted
$

But the only script that is able to run correctly is script2 since it exists in both the mounted and normal state. It does execute the mounted version (otherwise the log would show 2 normal).

Additional information

Workaround

Things work as expected when you create empty executable files in the normal (not mounted) folder that have the same name as the scripts you wan to run (that's why script2 worked).

Speculation

Termux:Tasker doesn't seem to be aware of the mount at all. The completion will show script1 and script2 (instead of script2 and script3). When executing it seems to check if the files are executable within Termux:Tasker before running it via Termux. Probably here:

if (!file.isFile()) {
errmsg = context.getString(R.string.no_regular_file_found);
}
// If path is not is TASKER_PATH or if read and execute errors must not be ignored for files in TASKER_PATH
else if (!isPathInTaskerDir || !ignoreErrorsForTaskerDir) {
// If file is not readable
if (!file.canRead()) {
errmsg = context.getString(R.string.no_readable_file_found);
}
// If file is not executable
// This check will give "avc: granted { execute }" warnings for target sdk 29
else if (!file.canExecute()) {
errmsg = context.getString(R.string.no_executable_file_found);
}
}

It will fail in a weird way for script1 (this task takes noticeably longer), which Termux:Tasker thinks is executable but actually is not. Script2 works as expected, because script2 is executable in the unmounted folder so Termux:Tasker lets it execute, which then executes script2 in the mounted folder. Termux:Tasker just refuses to execute script3 because it isn't in the unmounted folder, even though it would work.
I think it's a really interesting bug. I have no idea how to best solve it. Maybe have a force execution option in Termux:Tasker that skips the checks? I'd be interesting to see if there is a way to make Termux:Tasker aware of the mount, or to know why it isn't in the first place.

WHY?!

Mounting a folder to ~/.termux is pretty weird. This procedure is only the minimum required for the bug to occur. What I actually did and lead me to this bug is that I encrypted the whole /data/data/com.termux/files using a LUKS encrypted ext4 image, for which I wrote a neat tutorial here: https://glow.li/posts/encrypt-termux-fs/

  • Termux application version: 0.112
  • Android OS version: 9
  • Device model: FP3 (Fairphone)

Passing arguments to tasker

Is it possible to run sctipt with arguments? For example --tasker. It can be a default argument for all scripts

Get error when trying to use it in Tasker

When I try to select the plugin in Tasker I get the following error:
Error: plugin error: missing, disabled, not exported or no permission receiver, or too many receivers.

Script called from Tasker doesn't work correctly.

Hello,

first please bare with my low skills I am rather a user than developer..

In Tasker I have a task that creates a playlist with few videos from my subs.

In termux I wrote a small script that downloads that playlist and converts to mp3 with youtube-dl.
(the sh script for reference: https://pastebin.com/Wsqnvx1B , I use the files in the /variables dir as variables from tasker)

The script works flawlessly launched from within Termux with "./" but from Tasker it won't recognize the URL. When launching the script with terminal window I get this result:


ERROR: '' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:" ) to search YouTube

[Process completed (code 1) - press Enter]


It looks like the script won't read the file with the link when launched from Tasker..

Logcat: https://pastebin.com/guHXqMTx

I noticed "12.47.08#ActionArgBundle: error: Termux: replace specified for null or non-string extra: com.termux.tasker.extra.TERMINAL" in the first line but unfortunately I don't know what that means.

Any help would be much appreciated and I'm willing to provide any info. Thanks in advance.

Regards,

ionlyaskforeden

Installation failure, I am not even sure what caused it

Had both termux (FDroid) and other plugins installed, only Tasker won't install. Checked the logs, I am not even sure how to explain this. I need help.

12-24 01:44:00.576  1472  1549 E SELinux : SELinux:  setxattr failed: /data/app/com.termux.tasker-wmP69HJO5FGf_f0bLMbQvQ==:  Operation not permitted
12-24 01:44:00.576  1472  1549 E SELinux : SELinux:  setxattr failed: /data/app/com.termux.tasker-wmP69HJO5FGf_f0bLMbQvQ==/lib:  Operation not permitted
12-24 01:44:00.578  1472  1549 E PackageManager: Adding duplicate user id: 10163 name=com.termux.tasker
12-24 01:44:00.606  1472  1549 E Installer: Calling thread PackageManager is holding 0xce0ae85
12-24 01:44:00.606  1472  1549 E Installer: java.lang.Throwable
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.Installer.checkBeforeRemote(Installer.java:156)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.Installer.destroyAppData(Installer.java:209)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.destroyAppDataLeafLIF(PackageManagerService.java:9971)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.destroyAppDataLIF(PackageManagerService.java:9956)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.scanPackageNewLI(PackageManagerService.java:10488)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.scanPackageTracedLI(PackageManagerService.java:10255)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installNewPackageLIF(PackageManagerService.java:16892)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:18135)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installPackageTracedLI(PackageManagerService.java:17606)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.access$3300(PackageManagerService.java:407)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService$10.run(PackageManagerService.java:15436)
12-24 01:44:00.606  1472  1549 E Installer:     at android.os.Handler.handleCallback(Handler.java:873)
12-24 01:44:00.606  1472  1549 E Installer:     at android.os.Handler.dispatchMessage(Handler.java:99)
12-24 01:44:00.606  1472  1549 E Installer:     at android.os.Looper.loop(Looper.java:201)
12-24 01:44:00.606  1472  1549 E Installer:     at android.os.HandlerThread.run(HandlerThread.java:65)
12-24 01:44:00.606  1472  1549 E Installer:     at com.android.server.ServiceThread.run(ServiceThread.java:44)
12-24 01:44:00.608   680  1650 E         : Couldn't opendir /data/data/com.termux.tasker: No such file or directory
12-24 01:44:00.608   680  1650 E installd: Failed to delete /data/data/com.termux.tasker: No such file or directory
12-24 01:44:00.608   680  1650 E         : Couldn't opendir /data/user_de/0/com.termux.tasker: No such file or directory
12-24 01:44:00.608   680  1650 E installd: Failed to delete /data/user_de/0/com.termux.tasker: No such file or directory
12-24 01:44:00.634  1472  1549 W PackageManager: com.android.server.pm.Installer$InstallerException: android.os.ServiceSpecificException: Failed to delete /data/user_de/0/com.termux.tasker (code 2)
12-24 01:44:00.635  1472  1549 E Installer: Calling thread PackageManager is holding 0xce0ae85
12-24 01:44:00.635  1472  1549 E Installer: java.lang.Throwable
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.Installer.checkBeforeRemote(Installer.java:156)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.Installer.destroyAppProfiles(Installer.java:387)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.destroyAppProfilesLeafLIF(PackageManagerService.java:9994)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.destroyAppProfilesLIF(PackageManagerService.java:9985)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.scanPackageNewLI(PackageManagerService.java:10490)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.scanPackageTracedLI(PackageManagerService.java:10255)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installNewPackageLIF(PackageManagerService.java:16892)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:18135)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.installPackageTracedLI(PackageManagerService.java:17606)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService.access$3300(PackageManagerService.java:407)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.pm.PackageManagerService$10.run(PackageManagerService.java:15436)
12-24 01:44:00.635  1472  1549 E Installer:     at android.os.Handler.handleCallback(Handler.java:873)
12-24 01:44:00.635  1472  1549 E Installer:     at android.os.Handler.dispatchMessage(Handler.java:99)
12-24 01:44:00.635  1472  1549 E Installer:     at android.os.Looper.loop(Looper.java:201)
12-24 01:44:00.635  1472  1549 E Installer:     at android.os.HandlerThread.run(HandlerThread.java:65)
12-24 01:44:00.635  1472  1549 E Installer:     at com.android.server.ServiceThread.run(ServiceThread.java:44)
12-24 01:44:00.637  1472  1549 W PackageManager: Package couldn't be installed in /data/app/com.termux.tasker-wmP69HJO5FGf_f0bLMbQvQ==
12-24 01:44:00.637  1472  1549 W PackageManager: com.android.server.pm.PackageManagerException: Package com.termux.tasker has no signatures that match those in shared user com.termux; ignoring!
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerServiceUtils.verifySignatures(PackageManagerServiceUtils.java:629)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.commitScanResultsLocked(PackageManagerService.java:10596)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.scanPackageNewLI(PackageManagerService.java:10482)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.scanPackageTracedLI(PackageManagerService.java:10255)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.installNewPackageLIF(PackageManagerService.java:16892)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:18135)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.installPackageTracedLI(PackageManagerService.java:17606)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService.access$3300(PackageManagerService.java:407)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.pm.PackageManagerService$10.run(PackageManagerService.java:15436)
12-24 01:44:00.637  1472  1549 W PackageManager:        at android.os.Handler.handleCallback(Handler.java:873)
12-24 01:44:00.637  1472  1549 W PackageManager:        at android.os.Handler.dispatchMessage(Handler.java:99)
12-24 01:44:00.637  1472  1549 W PackageManager:        at android.os.Looper.loop(Looper.java:201)
12-24 01:44:00.637  1472  1549 W PackageManager:        at android.os.HandlerThread.run(HandlerThread.java:65)
12-24 01:44:00.637  1472  1549 W PackageManager:        at com.android.server.ServiceThread.run(ServiceThread.java:44)
12-24 01:44:00.640   680  1650 E cutils  : Failed to open(/data/misc/profiles/cur/0/com.termux.tasker/primary.prof): No such file or directory
12-24 01:44:00.640   680  1650 E installed: Failed to prepare /data/misc/profiles/cur/0/com.termux.tasker/primary.prof: No such file or directory
12-24 01:44:00.641  1472  1549 E ArtManagerService: Failed to prepare profile for com.termux.tasker:/data/app/com.termux.tasker-wmP69HJO5FGf_f0bLMbQvQ==/base.apk
12-24 01:44:00.646  1472  1549 I InstallationStatistic: com.termux.tasker|com.google.android.packageinstaller|1794|170|197|94|1057|0

No directory of ~/.termux/tasker

when go to tasker>plugin>configuration
it show message of No directory ~/.termux/tasker
I have try to add in various place still the same
PS: the app i download from F-droid for testing purpose, is it that only the play store version will work?

Where is the latest version?

Apologies for the silly question but the documentation refers to version 0.6.0. The latest release I see is 0.5. Am I not looking at the right place? Thank you.

Termux:Float Checkbox?

Can you add a checkbox (that would only be visible if the Termux:Float package was installed) to run the script in a Termux Float window? I've tried to figure out a way to do this but failed.

termux-tasker not working

thx

  • android 9.0 tasker 5.6
  • termux-tasker src compile
  • termux-app src compile
  • ~/.termux/tasker/aa.py
  • chmod +x ~/.termux/tasker/aa.py
  • $python ~/.termux/tasker/aa.py is ok
  • $~/.termux/tasker/aa.py is ok

but
tasker plugins not working

  • adb logcat |grep error nothing
  • adb logcat|grep termux nothing
  • adb logcat|grep tasker
2019-01-26 21:09:09.129 1120-1817/? I/AlarmManager: remove alarm:Alarm{972d1b6 type 0 when 1548508202913 PendingIntent{52b2b1d: PendingIntentRecord{ff26192 net.dinglisch.android.taskerm broadcastIntent}}net.dinglisch.android.taskerm} according to operation:a8ceeb7
2019-01-26 21:09:09.146 26680-26680/? D/HwAppInnerBoostImpl: asyncReportData net.dinglisch.android.taskerm,2,1,1,0 interval=144

Erro de Instalação

Screenshot_20210411-083233_NetHunter Store

Problem description

Steps to reproduce

Expected behavior

Additional information

  • Termux application version: Termux Task 0.4
  • Android OS version: 10
  • Device model: Samsung Galaxy A10 - SM-205G/DS

Task script with `termux-notification` hangs

Hello, any idea how can i debug this? i've tried pretty much everything i could think of, like with the tasker plugin action option to "execute in a terminal session" or not, setting termux/tasker/termux:tasker/termux:api to be able to run in the background without battery optimization. The process just hangs. Also testing the tasker action through tasker has the same behavior.
Running the script manually through termux works as expected.

Help

Hi can someone please help me, i had used termux boot to setup a script to run at boot

python sstvProxy.py -hl

hower, it is causing conflicts on my setup as the script is starting before other apps, can someone explain how i could use termux task to start the script a few mins after boot

Last update borked

After last play store update of this app, none of the tasker tasks containing the termux plugin works until you reenter the script files name. And the scripts seems to run start slower too

Cannot install: Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]

Problem description

I have Android 6. I have got older version of termux (v 0.118.0+605dd6c) that still runs well and I downloaded termux:tasker v 0.4 for Android 5. The APK did not install in phone, so I tried ADB install and got error

Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]

Is there any other method how to install?

Steps to reproduce

Expected behavior

Additional information

  • Termux application version:
  • Android OS version:
  • Device model:

Any way to get the stdout / stderr of python scripts?

Hello!

     Basically what the title says. I can't seem to get python scripts to output anything to the standard output or error, even when using sys.stdout.write() + sys.stdout.flush(); there seem to be constant permission errors to the scripts. I also ran termux-setup-storage, but no luck.

     Any help would be greatly appreciated!

Task executes asynchronously if runInTerminal == true

For tasks where runInTerminal == false, Tasker waits for the task to end (or for the timeout to elapse) before going on to the next action. This is also what I expected with runInTerminal == true, but what happens instead is that the task continues immediately. See attached video where Flash "Outside" happens as soon as the terminal is launched.

Not sure whether this is a bug report or feature request. If this behavior is unintended, then it's a bug report. I think, however, that the most user-friendly (and least surprising) thing to do, would be to add an option to wait (or not) for the termux task to finish before running the next action, regardless of runInTerminal.

Also pinging #16 which is related.

Make it possible to access Tasker variables from scripts

From https://www.reddit.com/r/tasker/comments/5mq7rc/psa_you_can_install_and_automate_things_like_curl/:

OK, so I'll just go with my own use-case as an example. I'm using Tasker to automatically write metadata to pictures as soon as I've taken them and exited the camera app. I do this by calling a Termux script from my Tasker task that runs perl exiftool [commands] /path/to/file.
In order for this to work, I obviously have to get the image file paths first of all. This is done by having Tasker read the camera folder and checking to see if there are image files that have been created since I last opened the camera app. The paths to these files are then stored in a local Tasker variable—let's say %paths.
Now I would like to pass this variable to the Termux script that I call at the end of my task in order to do something like perl exiftool [commands] $paths. What I have to do instead is write a text file in Tasker with the %paths variable and then have my Termux script read the information in that file to its own variable, which works but is kind of clunky.
I know I could rework my script to get the file paths directly in Termux, but it would be a lot more simple and versatile for a whole bunch of other use cases if it were possible to pass variables directly from Tasker.

Termux:Tasker MacroDroid

Problem description
MacroDroid
termux: tasker 0.4, 0.5 does not work. only the previous version is recognized

Additional information

  • Termux application version: 0.106
  • Android OS version: 10
  • Device model: SM-J400F

Tasker:Task crashes when choosing the plugin from within Tasker

I created the /data/data/com.termux/files/home/.termux/tasker folder and placed a shell script in it. The crash happens whether there is anything in that folder or not.

Nexus 5X
Android 7.1.1

Logcat:

---- Feb 12, 2017 11:20:17 AM ----

02-12 11:15:48.823  2234 28829 I ActivityManager: START u0 {act=com.twofortyfouram.locale.intent.action.EDIT_SETTING cmp=com.termux.tasker/.EditConfigurationActivity (has extras)} from uid 10130 on display 0

02-12 11:15:48.929  2234  2253 I ActivityManager: Start proc 1062:com.termux.tasker/u0a239 for activity com.termux.tasker/.EditConfigurationActivity

02-12 11:15:49.180  1062  1062 E AndroidRuntime: Process: com.termux.tasker, PID: 1062

02-12 11:15:49.180  1062  1062 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux.tasker/com.termux.tasker.EditConfigurationActivity}: java.lang.NullPointerException: Attempt to get length of null array

02-12 11:15:49.180  1062  1062 E AndroidRuntime: 	at com.termux.tasker.EditConfigurationActivity.onCreate(Unknown Source)

02-12 11:15:49.183  2234  9747 W ActivityManager:   Force finishing activity com.termux.tasker/.EditConfigurationActivity

02-12 11:15:49.696  2234  2266 W ActivityManager: Activity pause timeout for ActivityRecord{fb4f60e u0 com.termux.tasker/.EditConfigurationActivity t2776 f}

02-12 11:15:50.195  2234  5122 I ActivityManager: Process com.termux.tasker (pid 1062) has died

02-12 11:15:50.198  2234  9747 W ActivityManager: Ignoring remove of inactive process: ProcessRecord{762dfc4 0:com.termux.tasker/u0a239}

02-12 11:16:06.399  2234  6107 I ActivityManager: START u0 {act=com.twofortyfouram.locale.intent.action.EDIT_SETTING cmp=com.termux.tasker/.EditConfigurationActivity (has extras)} from uid 10130 on display 0

02-12 11:16:06.420  2234 25764 I ActivityManager: Start proc 1511:com.termux.tasker/u0a239 for activity com.termux.tasker/.EditConfigurationActivity

02-12 11:16:06.625  1511  1511 E AndroidRuntime: Process: com.termux.tasker, PID: 1511

02-12 11:16:06.625  1511  1511 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux.tasker/com.termux.tasker.EditConfigurationActivity}: java.lang.NullPointerException: Attempt to get length of null array

02-12 11:16:06.625  1511  1511 E AndroidRuntime: 	at com.termux.tasker.EditConfigurationActivity.onCreate(Unknown Source)

02-12 11:16:06.630  2234  2252 W ActivityManager:   Force finishing activity com.termux.tasker/.EditConfigurationActivity

02-12 11:16:07.135  2234  2266 W ActivityManager: Activity pause timeout for ActivityRecord{5f84d0c u0 com.termux.tasker/.EditConfigurationActivity t2776 f}

02-12 11:16:07.594  2234 22499 I ActivityManager: Process com.termux.tasker (pid 1511) has died

02-12 11:16:07.598  2234  2252 W ActivityManager: Ignoring remove of inactive process: ProcessRecord{bb7711b 0:com.termux.tasker/u0a239}

02-12 11:16:19.717  2234  6111 I ActivityManager: START u0 {act=com.twofortyfouram.locale.intent.action.EDIT_SETTING cmp=com.termux.tasker/.EditConfigurationActivity (has extras)} from uid 10130 on display 0

02-12 11:16:19.753  2234 28829 I ActivityManager: Start proc 1742:com.termux.tasker/u0a239 for activity com.termux.tasker/.EditConfigurationActivity

02-12 11:16:19.916  1742  1742 E AndroidRuntime: Process: com.termux.tasker, PID: 1742

02-12 11:16:19.916  1742  1742 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux.tasker/com.termux.tasker.EditConfigurationActivity}: java.lang.NullPointerException: Attempt to get length of null array

02-12 11:16:19.916  1742  1742 E AndroidRuntime: 	at com.termux.tasker.EditConfigurationActivity.onCreate(Unknown Source)

02-12 11:16:19.918  2234  5122 W ActivityManager:   Force finishing activity com.termux.tasker/.EditConfigurationActivity

02-12 11:16:20.426  2234  2266 W ActivityManager: Activity pause timeout for ActivityRecord{a012eaf u0 com.termux.tasker/.EditConfigurationActivity t2776 f}

02-12 11:16:20.723  2234  9749 I ActivityManager: Process com.termux.tasker (pid 1742) has died

02-12 11:18:27.966  2234  4662 I ActivityManager: START u0 {act=com.twofortyfouram.locale.intent.action.EDIT_SETTING cmp=com.termux.tasker/.EditConfigurationActivity (has extras)} from uid 10130 on display 0

02-12 11:18:28.074  2234 25765 I ActivityManager: Start proc 5345:com.termux.tasker/u0a239 for activity com.termux.tasker/.EditConfigurationActivity

02-12 11:18:28.159  5345  5345 W System  : ClassLoader referenced unknown path: /data/app/com.termux.tasker-1/lib/arm64

02-12 11:18:28.342  5345  5345 E AndroidRuntime: Process: com.termux.tasker, PID: 5345

02-12 11:18:28.342  5345  5345 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux.tasker/com.termux.tasker.EditConfigurationActivity}: java.lang.NullPointerException: Attempt to get length of null array

02-12 11:18:28.342  5345  5345 E AndroidRuntime: 	at com.termux.tasker.EditConfigurationActivity.onCreate(Unknown Source)

02-12 11:18:28.344  2234  2253 W ActivityManager:   Force finishing activity com.termux.tasker/.EditConfigurationActivity

02-12 11:18:28.852  2234  2266 W ActivityManager: Activity pause timeout for ActivityRecord{dfe94 u0 com.termux.tasker/.EditConfigurationActivity t2776 f}

02-12 11:18:32.027  2234 28830 I ActivityManager: Process com.termux.tasker (pid 5345) has died

02-12 11:18:32.031  2234  2253 W ActivityManager: Ignoring remove of inactive process: ProcessRecord{2126603 0:com.termux.tasker/u0a239}

---- Feb 12, 2017 11:20:17 AM ----

Commands that function when manually entered and not when executed in script

The following functions perfectly when manually entered into a Termux session:

rsync -avz -e ssh [email protected]:/home/XXX/Pictures/Snapshots /data/data/com.termux/files/home/downloads/Snapshots

The same command has been copied into an executable (chmod +x) script, but when I attempt to execute via the command line (./SyncSnapshots) or via the Tasker plugin, the following is returned:

via command line: bash: ./SyncSnapshots: Permission Denied

via Tasker plugin: exec("data/data.com.termux/files/home/.termux/tasker/SyncSnapshots"): Permission Denied

Termux:Task action executed asynchronously (i.e. doesn't make Tasker wait for it to finish)

I created a shell script in Termux that has the command "sleep 10" inside, and placed this in the ~/.termux/tasker directory. In Tasker, I created a Task with 2 actions. The first one is Termux:Task that executes the shell script. The second is a Flash action that simply pops up a window with an "Awake" message.

When I run the task, the second action immediately gets executed, without waiting for the first to finish.

I'm not sure if Termux:Task is meant to execute asynchronously or synchronously, i.e. whether this is a feature or a bug. I saw this Tasker guide on how to create plugins, and tried to read the source code to find out whether the synchronous settings are there or not. Unfortunately, things went way over my head very quickly, so I decided to open this issue instead.

I currently have a way around this asynchronous behaviour. In Tasker, I add an action right after the Termux:Task action that will make Tasker wait until a Tasker variable is set, before proceeding to the next action. Then on the Termux script level, I add a line at the end of my script which sets this Tasker variable using the technique I learned from glow's blog. It's a bit kludgy though, and I would rather do things natively in Termux, if I could only make Termux behave synchronously.

For all I know, asynchronicity is what other users want. I myself can imagine scenarios where that could be handy. Perhaps it would be nice to have a way, for example via a termux.properties global setting or a checkbox within the Termux:Task action, where the user can set whether Termux:Task should make Tasker wait for it to finish or not?

Stdin still expects a file/path

Problem description
I am trying to run a shell-command only using stdin, without creating a shell script file. The docs say "use stdin", but after entering my command into stdin, it still expects an executable (file path).
When going back (and ignoring the message), it says "Error: no plugin configuration data.".

Steps to reproduce

  1. Create a task and use termux plugin
  2. Enter a command in stdin, e.g. ping -c 1 google.com
  3. Leave "Executable" field empty
  4. Click done and go back

Expected behavior
Should not expect an executable file, when std in is used.
Ideally, the user should be able to choose, wether to use an executable or stdin.

Additional information

  • Termux application version: 0.118.0
  • Android OS version: 12
  • Device model: Pixel 3 XL

Unable to install

Unable to install ... tried both download apk and via F-droid.
I get "App not installed."

  • Termux application version: 0.101
  • Android OS version: 10
  • Device model: galaxy s9

Run scripts from the location they are saved in, instead of the destination of the softlink.

Feature description

When I run python, I use a virtual environment located inside the Tasker folder. However, the Python binaries there are actually softlinks to the system Python. Running them from inside the folder adds the virtual environment's packages to the python path, but running it from outside doesn't give you access to those packages.

Right now, when I need to run from inside a virtual environment, I import sys and add the library path to it. It happened so often that I just made a task that does that and pastes in the rest of the code into an empty file that I then run.

Run scripts in sdcard

Could you please add support to run scripts in sdcard? It is much easier to edit and backup scripts in sdcard. Thanks!

The argument not support file paths

What I've set as pointer to a file

I've pointed a file to work with node in the arguments field. But the results comes out as nothing. Is it not working! Or the argument is taking the string as normal letters or am I missing something!

`allow-external-apps` property not recognized if `~/.termux/termux.properties` is a symlink

Problem description

On my system, ~/.termux/termux.properties is a symlink, and the source file contains allow-external-apps = true.
Termux:Tasker 0.6.0 doesn't seem to see the file or setting. It worked in the previous version, 0.5.

Screenshot_20220225-184843294 (1)
Screenshot_20220225-184946444 (1)

Steps to reproduce

Move ~/.termux/termux.properties elsewhere and create a symlink in its place:

mv ~/.termux/termux.properties ~/
ln -s ~/termux.properties ~/.termux/termux.properties

Create a Tasker task that calls an executable outside of ~/.termux/tasker, for example /data/data/com.termux/files/usr/bin/nano

It won't work, Tasker will show an error.

Expected behavior

The executable should be called.

Additional information

  • Termux application version: 0.118.0
  • Termux:Tasker application version: 0.6.0
  • Android OS version: 11
  • Device model: OnePlus 8

Interpreter/shebang bug

The shebang path to /usr/bin/env works fine when running youtube-dl straight from termux, but when using the tasker plugin it caused the program to fail. When the binary was edited to /bin/env the program ran as expected. It seems that whatever prefixing/redirecting Termux does for the interpreter was not integrated into the Termux: Task plugin.

Scripts launched from Macrodroid

Hi,
I'm a new user of Termux (and Termux Tasker) and I'd like to copy files from /sdcard to /data/user/0/ using Macrodroid.

Macrodroid tells me that I need to create this directory:

No ~/.termux/tasker/ directory
You need to create a ~/.termux/tasker/ directory containing scripts to be executed.

AFAIK /home of Termux is /data/data/com.termux/files/home/ so I tried to create it using mkdir ~/.termux/tasker. Result
So I've created it manually.

I still have this same message on Macrodroid.
I installed Termux app and this one (installed from F-Droid). I own a OnePlus 3T running an Oreo 8.1 AOSP based ROM.

Thank you for your help.

PS: the script I created is very and I think it should work:
#!/data/data/com.termux/files/usr/bin/sh
cp /sdcard/Download/test.xml /data/data/user/0/...../test.xml

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.