Useful usage of Termux:Tasker(tudo wrapper)

Dimlos

Well-known member
Normally, when using Termux:Tasker, you need to prepare a script and specify a file to use it, but by setting up tudo, you can write code directly in Arguments.


tudo setup
1.pkg install vim
2.pkg install curl
3.curl -L 'https://github.com/agnostic-apollo/tudo/releases/latest/download/tudo' -o "/data/data/com.termux/files/usr/bin/tudo"
4.export termux_bin_path="/data/data/com.termux/files/usr/bin"; export owner="$(stat -c "%u" "$termux_bin_path")"; chown "$owner:$owner" "$termux_bin_path/tudo" && chmod 700 "$termux_bin_path/tudo";
5.sed -i -e "s/# allow-external-apps = true/allow-external-apps = true/" /data/data/com.termux/files/home/.termux/termux.properties

See sample macros and screenshots for how to write code to Termux:Tasker.
 

Attachments

  • Macro.jpg
    Macro.jpg
    107.4 KB · Views: 84
  • Plugin.jpg
    Plugin.jpg
    101 KB · Views: 83
  • properties.jpg
    properties.jpg
    255.1 KB · Views: 78
  • tudo_sample.macro
    5.4 KB · Views: 30
Last edited:

sampleuserhere

Active member
Do you know any other parameter that allows us to pass the whole script with multiple line besides encoding them to base64? -s --script-decode "%script"

I'm trying to create a wrapper with action block. My shell script runtime hasn't been too good yet, so I couldn't rely on base64 package that comes within android toybox to encode the script.[/CODE]
 

Dimlos

Well-known member
I'm not quite sure what you want to do, but maybe this sample will help?
 

Attachments

  • Macro.jpg
    Macro.jpg
    457.4 KB · Views: 31
  • tudo(multiple_line).macro
    6.1 KB · Views: 14

sampleuserhere

Active member
Oh I see that works too! I just have to escape ' with '\'' like the usual.

However it doesn't seem like I could return the stdout directly from termux though. Is there any specific settings I have to set up in Macrodroid to do this?
 

Dimlos

Well-known member
Does this mean that standard output is not returned even if I do not use tudo?
Are you excluding Termux or Termux:Tesker from battery optimization?
 

Endercraft

Moderator (& bug finder :D)
What I do and is easier to set up is make a script which uses every passed argument.
Code:
$1 $2 $3 $4 $5 $6 $7 $8 $9
And so on.
 

sampleuserhere

Active member
Does this mean that standard output is not returned even if I do not use tudo?
Are you excluding Termux or Termux:Tesker from battery optimization?

Yes, I tried executing /data/data/com.termux/files/usr/bin/base64 while passing the text as stdin. It didn't return anything to Macrodroid (5.38.9 on A12), while it did to Tasker.

Both apps are excluded from battery optimization, I also maximized the value of phantom process killer as well.

I wonder what happened?

I may have to look into the log later.

What I do and is easier to set up is make a script which uses every passed argument.
Code:
$1 $2 $3 $4 $5 $6 $7 $8 $9
And so on.

Thanks for the suggestion, but that would beat the purpose of using tudo.
 

sampleuserhere

Active member
The variable got populated again after I tried downgrading and upgrading the apk. The termux log didn't tell any odd behaviour either so I couldn't exactly pinpoint which one caused that.

Anyhow, I appreciate the answer @Dimlos. It turns out that I don't have to encode the script into base64 after all. Thankyou very much!
 

sampleuserhere

Active member
I'm not sure how but I just tried running a command and it worked.

Here's the way I do things.

Let's say the script is stored under a local variable called script in MD, then we can pass -s '%script' as the argument with tudo location as the executable path.

If the script contains ' then the single quote should be replaced (escaped) with '\''.

It's also better to pass a local variable that contains only lower case characters. I'm having a hard time describing the syntax but the local variable should at least matches the following regexp ^%[a-z0-9][a-z0-9_]+[a-z0-9]$ otherwise the plugin won't recognises them as local variable, this is afaik about Tasker syntax.
 

Dev777

Active member
Hi guys I need help.
I need this command to list running apps. It works fine on Termux but on Termux:tasker it throws this error.
Anyway to fix it? Thanks in advance

This is the command:



adb shell dumpsys activity processes | grep -E 'APP.*ProcessRecord\{' | sed 's/\*APP.*://g' | sed 's/\/.*$//g'
 

Attachments

  • Screenshot_2023-11-01-21-24-48-508_com.arlosoft.macrodroid.jpg
    Screenshot_2023-11-01-21-24-48-508_com.arlosoft.macrodroid.jpg
    355.3 KB · Views: 12

Dimlos

Well-known member
I don't know if this is the right answer, but the error no longer occurs.
adb shell dumpsys activity processes | grep -E 'APP.*ProcessRecord\{' | sed "s/\*APP.*://g" | sed "s/\/.*$//g"
 

Dev777

Active member
I don't know if this is the right answer, but the error no longer occurs.
adb shell dumpsys activity processes | grep -E 'APP.*ProcessRecord\{' | sed "s/\*APP.*://g" | sed "s/\/.*$//g"
Thanks. Unfortunately I'm getting the same error again. Maybe it's a problem with my environment for Termux:tasker
 
Top