So, I'm still trying to get this stuff to work natively in Automate, and feeling kinda dumb. I
was able to get it to work
immediately with the Tasker Termux plugin, called by Automate (as long as I turned off the "timeout" option)...but I can't seem to do it with Automate directly. Note that I also tried just calling the script from a shell block, and that didn't work either.
So, I've followed the steps you referenced above and have turned on the ability to run commands with:
$ cd ~/.termux
$ cat termux.properties
allow-external-apps=true
$
Of course, I also have the ability turned on in Automate's permissions. I then tried to use a Start Application block, but that can't work: referencing the Termux source here
I discovered that it's definitely a service, and so I needed to start a service, So I tried that:
And I get this:
-30 12:36:13.580 I 172@7: File exists?
12-30 12:36:13.584 I 172@14: Service start
12-30 12:36:13.585 F 172@14: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.termux.RUN_COMMAND cmp=com.termux/.app.RunCommandService (has extras) }: app is in background uid UidRecord{40bce6e u0a398 CEM bg:+1h19m51s559ms idle change:idle procs:1 seq(0,0,0)}
12-30 12:36:13.585 I 172@14: Stopped by failure
I did it with and without RUN_COMMAND_BACKGROUND, and restarted the phone, too.
I checked to see if I need to let Termux draw over things: that didn't seem to help.
Again, I feel like I'm missing something quite simple, but I don't know what it is. Since it's all working with the Tasker plugin in this same environment, I know it's possible (since they must be doing it this same way), and don't begrudge them the $2, I'm basically now just trying to figure out what I did wrong so I don't have to bug you folks the next time through.
Note, too: I was able to get it to work natively in Termux by using inotifywait and calling the same script, which was nice--always amazes me what can be accomplished in Android, with a little work; even if the user experience isn't quite up to iOS standards, the utility of this stuff far surpasses anything that I can do on iOS without actually writing an entire application (and even then).
It's also rather nice that the same basic bash scripts work on Android/Termux, macOS and Windows WSL, with small modifications for how you have to launch apps on each (I should work on detecting the environment and literally sharing the entire script).