Skip to content

Instantly share code, notes, and snippets.

@davebrny
Created June 13, 2022 16:13
Show Gist options
  • Save davebrny/a3794d266fa0098a7c82ac658b3b8203 to your computer and use it in GitHub Desktop.
Save davebrny/a3794d266fa0098a7c82ac658b3b8203 to your computer and use it in GitHub Desktop.
(python, termux) run python scripts outside of the .termux/tasker folder
#!/data/data/com.termux/files/usr/bin/python
import sys
import subprocess
file = sys.argv[1]
args = ' '.join(map(str, sys.argv[2:]))
subprocess.run(['python', file, args])
@davebrny
Copy link
Author

davebrny commented Jun 13, 2022

the termux plugin seems to return the stdout with a linefeed at the end and i cant figure out how to get rid of it so i made a task that runs the termux plugin and then trims any whitespace when anything is returned. its a bit easier to add/edit arguments since you can just put the python script path in the %par1 section and arguments in %par2

curl command to download it to your tasker folder:

curl https://gist.githubusercontent.com/davebrny/a410b08acf7a776926cd0cf4ddead77b/raw/python_termux.tsk.xml \
    --output /storage/emulated/0/Tasker/tasks/python_termux.tsk.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment