1604448827988 1607249956160 978 Termux Tasker Plugin Basic Templates 100 A task that provides templates for running basic commands with the Termux:Tasker plugin. This task requires Termux:Tasker version `>= 0.5`. Tasker must be granted `com.termux.permission.RUN_COMMAND` permission. The `termux_tasker_basic_bash_test` and `termux_tasker_basic_python_test` scripts must be installed at `~/.termux/tasker/termux_tasker_basic_bash_test` and `~/.termux/tasker/termux_tasker_basic_python_test` respectively. The Template 4 will also require the `allow-external-apps` property to be set to `true` in `~/.termux/termux.properties` file since the `$PREFIX/bin/bash` absolute path is outside the `~/.termux/tasker/` directory, otherwise its plugin action will fail. For android `>= 10`, Termux must also be granted `Draw Over Apps` permissions so that foreground commands automatically start executing without the user having to manually click the `Termux` notification in the status bar dropdown notifications list for the commands to start. Check [Termux:Tasker Github](https://github.com/termux/termux-tasker) for more details on plugin configuration and variables and how to handle them. Template 1 runs the `~/.termux/tasker/termux_tasker_basic_bash_test` `bash` script in the background and sends it 2 simple constant string args and gets the result back in `%stdout`. The args sent do not contain any quotes or special characters and can simply be sent surrounded with double quotes. Template 2 runs the `~/.termux/tasker/termux_tasker_basic_bash_test` `bash` script in the background and sends it 2 complex dynamic args that may contain quotes or special characters, basically a literal string. The result is received back in the `%stdout` variable. The `termux_tasker_basic_bash_test` executable is passed to the plugin using the `%executable` variable. The `%argument_1` and `%argument_2` variables are used to store the dynamic values to be sent as `$1` and `$2` respectively to `termux_tasker_basic_bash_test` and are sent surrounded with single quotes instead of double quotes. They are first set in the `%arguments` variable surrounded with single quotes and separated by a whitespace which is passed to the plugin. The `%argument_1` and `%argument_2` variables may contain any type of characters, even a single quote, but single quotes must be escaped before the plugin action is run. To escape the single quotes, `Variable Search Replace` action is run to replace all single quotes `'` with one single quote, followed by one backslash, followed by two single quotes `'\''`. So `%arguement_1` 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 as `$1`. The `Variable Search Replace` action must be used separately for each argument variable before adding it to the `%arguments` variable. Do not set multiple arguments in the same variable and use `Variable Search Replace` action on it since that will result in incorrect quoting. This template shows how you can dynamically create plugin commands at runtime using variables and send them to the plugin for execution. Template 3 is the same as Template 2, but it runs the `~/.termux/tasker/termux_tasker_basic_python_test` `python` script instead in the background. It can be used as a template to run `python` scripts instead of `bash` scripts. Template 4 runs `$PREFIX/bin/bash` commamd in the foreground to print the path of the current working directory in a foreground terminal session. It does this by passing `echo "I'm in '$(pwd)'"; sleep 5;` to `bash` `-c` option after appropriate escaping. The default value of working directory is set to `~/`. Since commands will be run in a foreground terminal session, the `%stdout`, `%stderr` and `%result` variables will not be returned and only `%err` and `%errmsg` may be returned if the action fails. The `$PREFIX/` is a shortcut for the termux prefix directory `/data/data/com.termux/files/usr/`. The `~/` is a shortcut for the termux home directory `/data/data/com.termux/files/home/`. These shortcuts can be used in the `Executable` and the `Working Directory` plugin fields. The scripts or binaries in the `~/.termux/tasker/` directory do not require them to prefixed with the full path, just set the name in the `Executable` field, like its done for `termux_tasker_basic_bash_test` script in Template 1 and 2 and `termux_tasker_basic_python_test` in Template 3. The `%command_failed` variable will be set if the plugin action failed, this is detected by whether `%err` or `%errmsg` is set by the plugin action or if `%result` does not equal `0` for background commands. If you run multiple plugin actions in the same task or are using `Local Variable Passthrough`, then you must clear the `%command_failed` variable and optionally the `%errmsg`, `%stdout`, `%stderr` and `%result` variables with the `Variable Clear` action before running each plugin action, in case they were already set, like by a previously failed plugin action after which the task was not stopped. To debug arguments being passed or any errors, you can check `logcat` after increasing log level to `Debug`. Check `Debugging` section of `README.md` for more details. ## **Parameters:** `-` **Returns:** `-` **Control:** ``` version_name: 0.1.0 ```

false

300 547 %task_name Termux Tasker Plugin Basic Templates 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 1 Command Failed %command_failed OK 137 43 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 1 Command Result stdout = ``` %stdout ``` stderr = ``` %stderr ``` OK 38 300 300 135 false Template 3 Start 300 547 %argument_1 json 300 547 %argument_2 { "name":"I'm Termux", "license":"GPLv3", "addons": { "1":"Termux:API", "2":"Termux:Boot", "3":"Termux:Float", "4":"Termux:Styling", "5":"Termux:Tasker", "6":"Termux:Widget" } } 598 %argument_1 ' '\\'' %argument_1 12 598 %argument_2 ' '\\'' %argument_2 12 547 %executable termux_tasker_basic_bash_test 547 %arguments '%argument_1' '%argument_2' 549 %command_failed/%errmsg/%stdout/%stderr/%result 1256900802 false %arguments java.lang.String %executable java.lang.String false java.lang.Boolean 4 java.lang.Integer java.lang.String %executable %arguments java.lang.String <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%stdout Standard Output The &lt;B&gt;stdout&lt;/B&gt; of the command.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1>%stderr Standard Error The &lt;B&gt;stderr&lt;/B&gt; of the command.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2>%result Exit Code The &lt;B&gt;exit code&lt;/B&gt; of the command. 0 often means success and anything else is usually a failure of some sort.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2></StringArray> [Ljava.lang.String; com.termux.tasker.extra.EXECUTABLE com.termux.execute.arguments com.termux.tasker.extra.WORKDIR java.lang.String true java.lang.Boolean com.termux.tasker com.termux.tasker.EditConfigurationActivity 547 %command_failed err = `%err` errmsg = ``` %errmsg ``` exit_code = `%result` stdout = ``` %stdout ``` stderr = ``` %stderr ``` Or Or %err 12 %errmsg 12 %result 1 0 37 %command_failed 12 \%err \%errmsg 598 false %command_failed ^err = `\%err`[\n]+errmsg =[\n]```[\n]\%errmsg[\n]```[\n]+ %command_failed 12 135 false Template 2 Start 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 2 Command Failed %command_failed OK 137 43 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 2 Command Result stdout = ``` %stdout ``` stderr = ``` %stderr ``` OK 38 300 300 135 false Template 4 Start 300 547 %argument_1 json 300 547 %argument_2 { "name":"I'm Termux", "license":"GPLv3", "addons": { "1":"Termux:API", "2":"Termux:Boot", "3":"Termux:Float", "4":"Termux:Styling", "5":"Termux:Tasker", "6":"Termux:Widget" } } 598 %argument_1 ' '\\'' %argument_1 12 598 %argument_2 ' '\\'' %argument_2 12 547 %executable termux_tasker_basic_python_test 547 %arguments '%argument_1' '%argument_2' 549 %command_failed/%errmsg/%stdout/%stderr/%result 1256900802 false %arguments java.lang.String %executable java.lang.String false java.lang.Boolean 4 java.lang.Integer java.lang.String %executable %arguments java.lang.String <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%stdout Standard Output The &lt;B&gt;stdout&lt;/B&gt; of the command.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1>%stderr Standard Error The &lt;B&gt;stderr&lt;/B&gt; of the command.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2>%result Exit Code The &lt;B&gt;exit code&lt;/B&gt; of the command. 0 often means success and anything else is usually a failure of some sort.</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2></StringArray> [Ljava.lang.String; com.termux.tasker.extra.EXECUTABLE com.termux.execute.arguments com.termux.tasker.extra.WORKDIR java.lang.String true java.lang.Boolean com.termux.tasker com.termux.tasker.EditConfigurationActivity 547 %command_failed err = `%err` errmsg = ``` %errmsg ``` exit_code = `%result` stdout = ``` %stdout ``` stderr = ``` %stderr ``` Or Or %err 12 %errmsg 12 %result 1 0 37 %command_failed 12 \%err \%errmsg 598 false %command_failed ^err = `\%err`[\n]+errmsg =[\n]```[\n]\%errmsg[\n]```[\n]+ %command_failed 12 549 %command_failed/%errmsg/%stdout/%stderr/%result 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 3 Command Failed %command_failed OK 137 43 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 3 Command Result stdout = ``` %stdout ``` stderr = ``` %stderr ``` OK 38 300 300 135 false Return 300 549 %command_failed/%errmsg/%stdout/%stderr/%result 1256900802 false "hello," "termux!" java.lang.String termux_tasker_basic_bash_test java.lang.String false java.lang.Boolean 4 java.lang.Integer java.lang.String termux_tasker_basic_bash_test "hello," "termux!" java.lang.String com.termux.tasker.extra.EXECUTABLE com.termux.execute.arguments com.termux.tasker.extra.WORKDIR java.lang.String true java.lang.Boolean com.termux.tasker com.termux.tasker.EditConfigurationActivity 1256900802 false -c "echo \"I'm in '$(pwd)'\"; sleep 5;" java.lang.String $PREFIX/bin/bash java.lang.String true java.lang.Boolean 4 java.lang.Integer ~/ java.lang.String $PREFIX/bin/bash -c "echo \"I'm in '$(pwd)'\"; sleep 5;" ✓ java.lang.String com.termux.tasker.extra.EXECUTABLE com.termux.execute.arguments com.termux.tasker.extra.WORKDIR java.lang.String true java.lang.Boolean com.termux.tasker com.termux.tasker.EditConfigurationActivity 547 %command_failed err = `%err` errmsg = ``` %errmsg ``` Or %err 12 %errmsg 12 37 %command_failed 12 \%err \%errmsg 377 <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%td_button Button The label of the button that was clicked</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0></StringArray> [Ljava.lang.String; Template 4 Command Failed %command_failed OK 137 38 300 300 547 %command_failed err = `%err` errmsg = ``` %errmsg ``` exit_code = `%result` stdout = ``` %stdout ``` stderr = ``` %stderr ``` Or Or %err 12 %errmsg 12 %result 1 0 37 %command_failed 12 \%err \%errmsg 598 false %command_failed ^err = `\%err`[\n]+errmsg =[\n]```[\n]\%errmsg[\n]```[\n]+ %command_failed 12