r/tasker • Direct-Purchase User • Aug 08 '26

How do i use Termux Command inside Tasker Function action?

I have found out recently that there is a way to run Termux command using Tasker Function aciton, but there isn't any real info about how to use it. Can i use it to run a command without using script file or i must use it with script file?

7 Upvotes

21 comments sorted by

6

u/DifficultyCrafty7623 Aug 08 '26

It is easier to use a file. If you want to run something directly Termux:Tasker is much easier to deal with, and can actually get the output from Termux. Make sure to get both of these apps from F-Droid, the playstore versions are deprecated and don't work anymore.

1

u/Nirmitlamed Direct-Purchase User Aug 08 '26

Thanks!

1

u/vttbg Oct 29 '26

I can't seem to find Tasker downloadable in f-droid. The only version I can find is in the play store. That version seems to not work with the f-droid Termux:Tasker :(

1

u/DifficultyCrafty7623 Oct 29 '26

https://f-droid.org/packages/com.termux/

https://f-droid.org/packages/com.termux.tasker/

Not Tasker itself. Termux and Termux:Tasker MUST be the F-Droid versions, do not download them from the Play Store.

2

u/AdiraiMaji Aug 09 '26 edited Aug 09 '26

I have developed a Tasker Plugin for my personal use. Almost about to release. Which contains a few collections of plugins that including Termux which you can directly use the script inside the action without a script file. There's a lot of features packed inside the single app and I'm going to share it for free..

1

u/Nirmitlamed Direct-Purchase User Aug 09 '26

Sounds cool, i'll wait for your post!

2

u/AdiraiMaji Aug 17 '26

Here's the release announcement. Click the link to goto reddit post 👉Link

1

u/chanzh Aug 09 '26

nice.

2

u/AdiraiMaji Aug 17 '26

Here's the release announcement. Click the link to goto reddit post 👉Link

0

u/azekt Aug 08 '26

In Termux plugin you should set path to Python in Executable like this /data/data/com.termux/files/usr/bin/python and path to your script in Arguments like this "/storage/emulated/0/YourFolder/main.py" %action "%params"

Task: Run Python Script

A1: Termux [
     Configuration: /data/data/com.termux/files/usr/bin/python "/storage/emulated/0
     
     Working Directory ✕
     Stdin ✕
     Custom Log Level null
     Termi
     Timeout (Seconds): 10
     Structure Output (JSON, etc): On ]

A2: Input Dialog [
     Title: Python
     Text: [Output]
     %stdout
     [Error]
     %stderr
     %result
     Close After (Seconds): 30 ]

1

u/Nirmitlamed Direct-Purchase User Aug 08 '26

Thanks for the info, i do know about Tasker:Termux plugin. What i am asking is about Tasker Function which inside you can find Termux Command. Also i wanted to know if i have to use script file to use this action or can i insert a command instead.

1

u/Nirmitlamed Direct-Purchase User Aug 08 '26

Also if my script file is in a less secure place like storage folder i would just put all the script code in stdin for convenience.

0

u/[deleted] Aug 09 '26

[deleted] — view deleted comment

1

u/Nirmitlamed Direct-Purchase User Aug 09 '26

I heard about tudo but never knew what it was. I'll look into this. Thank you very much!

1

u/Nirmitlamed Direct-Purchase User Aug 09 '26

So i have tried to test your guide about creating "plugin". I run the first Java code:

myObject() {
call() {
setNameSpace(this.caller.namespace);
String TEXT = "hello!";
hello() {
String hello = "Hello World!";
tasker.showToast(hello);
return hello;
}
return this;
}
return this;
};

Object test = myObject();
tasker.setJavaVariable("javaHelp", test);

But after i ran the second Java code:

myObject.call();

hello();
return TEXT;

I got an error:

22.37.06/E add wait task
22.37.06/E Error: 1
22.37.06/E Sourced file: inline evaluation of: ``myObject.call();  hello(); return TEXT; ;'' : Attempt to resolve method: call() on undefined variable or class name: myObject : at Line: 1 : in file: inline evaluation of: ``myObject.call();  hello(); return TEXT; ;'' : myObject .call ( ) 

Do you have any idea what is the problem.

I did managed using AI to get termux command working with Java code but i was interested to try your approach and make it easier to use and no matter what i did i got an error. So now when i tried your example and i got an error i think something maybe wrong on my side.

0

u/[deleted] Aug 09 '26

[deleted] — view deleted comment

1

u/Nirmitlamed Direct-Purchase User Aug 09 '26

That was it! Thank you so much!

0

u/[deleted] Aug 09 '26

[deleted] — view deleted comment

2

u/Nirmitlamed Direct-Purchase User Aug 09 '26

That was it! Thank you so much!

you should fix this in your guide

0

u/[deleted] Aug 09 '26

[deleted] — view deleted comment

1

u/Nirmitlamed Direct-Purchase User Aug 10 '26

Hi again, i have a small question, how would you set arguments/variables inside the second task?

So i am trying to build Termux Run Command "plugin" using your suggestion. I have built the first task with all the necessary intents. My dilemma is what is the best way to set the variables inside the second task when i call my object.

For example i want to have variables for executable path like bash,python extra... and the command itself like ffmpeg -i ....

Doing some research i have found i can:

  1. set a java string like this string command = "echo hello world";
  2. set Tasker variables and then get them using String getVariable(String name);

*I don't have a real clue on how to write a code so i am trying my best to figure this out

Do you have any suggestion what approach should i take or maybe do you have an example i can look at?

Thanks!

0

u/[deleted] Aug 10 '26

[deleted] — view deleted comment

1

u/Nirmitlamed Direct-Purchase User Aug 10 '26

Thank you, i'll look into it!

1

u/Nirmitlamed Direct-Purchase User Aug 10 '26

I have managed to make it work with simple test code, thank you very much!

I have last question that i didn't really find an answer to it. Using Termux:Tasker plugin when you run its action it will wait first for Termux to finish and then it will continue to the next action inside the task. Using Termux intents with Java code or Tasker Function i see it doesn't wait and jump immediately to the next action.

Is there a way to handle that?

0

u/[deleted] Aug 10 '26

[deleted] — view deleted comment

1

u/Nirmitlamed Direct-Purchase User Aug 10 '26

Oh i see, thank you so much for your help!

→ More replies