# Owner: glow # KeyID: E65A8520F36AEE13CFE4F56BEB8FE331063A4794 # Key: https://glow.li/pgp # Verify: curl "https://glow.li/posts/pass-variables-from-termux-to-tasker/index.html.asc" | gpg -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 - --- date=2016-04-03 layout=post title="Pass variables from Termux to Tasker" tags[]=Technology tags[]=Termux tags[]=CLI tags[]=Tasker tags[]=Android tags[]=Tutorial oldurls[]=technology/2016/4/03/pass-variables-from-termux-to-tasker/ - --- 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 ![Screenshot](/media/images/small/TaskerVolume1.webp){.right} 1. Create a new profile 2. Choose "Event" 3. In the "Select Event Category" dialog choose "System"->"Intent Received" 4. As Action define `net.dinglish.tasker.volume` This profile will now be called whenever it receives the "volume" intent. ### Step 3: Create the Task ![Screenshot](/media/images/small/TaskerVolume2.webp){.right} 1. Tap "New Task" and give it a name 2. Tap + to add a new Action 3. Choose "Audio"->"Media Volume" 4. Under "Level" tap the icon with the crossing arrows to switch to text mode. 5. Enter `%volume` as a value 6. 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. -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE5lqFIPNq7hPP5PVr64/jMQY6R5QFAmHoUIoACgkQ64/jMQY6 R5TNVQ//bbBtJUBEmEXzCdkb6cjFkqVi0xFjNvQev+WwKhjF1mhEbhLCeF3xPICz PnK4oLLcWEzZ5AO6QDFgLUJnZEqolAJsC3e//RbMfekKbR18LQUqRAiOKHhzOtu4 o8MOL2wScISyvOaSgZZUgzILxoQ+oB26sxUj0NuBlul1wudYRDO4O6O9Vila1VEM IZ86fi5G4DbtsPGinfVa8ooT7wUpeBqh3pXydoIPCraxJrVJpnsSrcdPzRYIgtQv cWDGT98I64SANAXWQwL8CLpM8Fy+6a3NLz2OStYiXoCuB61OaA+mJaC+7jLnAcAf AA9ZMaiD6gZGg4qkO9Bto3id5eRseCG1Kk5O9FqsUMVagHwo2Uupju6vVKHrZqlI uwV4xToWl25+mxYPy6Fo3Pq9G4XutZoEv3l7MVReiJ/IY2ZIvfp83NvVAmQql9+s ND0XWlIJvCXFZFcl0t5MwSe18CDw9dOlAsjWksTFYzh9Gpt1viMYnQ7DCYaQOwT4 KZIOu5aGqWgG8DiyKTNQcBmE/uYrkfvFLTwBI8SzUrtt2W0qy4kNFMI82rdg7uW9 0WOZHnOxxwF/K7WSJTLqKAGj6aox24urGhg1VuJVSX1FkyUZ3nVq59h+plYwiyyS xeQePKEQYEh7BJAPkilgmdWH0AUCh5BZyiPA5YAzEGckN1iPs50= =LXu4 -----END PGP SIGNATURE-----