I figured out that you can pass variables from Termux to a Tasker task. This example sets Android's volume to a value specified in Termux.
Step 1: Creating the script
volume.sh
#!/data/data/com.termux/files/usr/bin/sh
#am broadcast --user 0 -a net.dinglish.tasker.[task name] -e [variable name] "[value]" > /dev/null
am broadcast --user 0 -a net.dinglish.tasker.volume -e volume "$1" > /dev/null
Step 2: Create a Tasker profile
- Create a new profile
- Choose "Event"
- In the "Select Event Category" dialog choose "System"->"Intent Received"
- As Action define
net.dinglish.tasker.volume
This profile will now be called whenever it receives the "volume" intent.
Step 3: Create the Task
- Tap "New Task" and give it a name
- Tap + to add a new Action
- Choose "Audio"->"Media Volume"
- Under "Level" tap the icon with the crossing arrows to switch to text mode.
- Enter
%volume
as a value - You need to exit Tasker for the changes to take effect.
Step 4: Run the script
You can now run the script. It will send an intent to Tasker. It will put the first argument as new volume, which has to be an integer from 0-15.
./volume.sh 4
This is only a simple example of what you can do with variables. Let me know what you come up with.