# 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", "oldurls": ["technology/2016/4/03/pass-variables-from-termux-to-tasker/"], "tags": ["Technology", "Termux", "CLI", "Tasker", "Android", "Tutorial"], "title": "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/TaskerVolume1){.right .size-half} 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/TaskerVolume2){.right .size-half} 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/jMQY6R5QFAmRuqFoACgkQ64/jMQY6 R5QipRAAlYvcU6jP5jTVil6jotmCnslk9vz7BRay0s+IVluFDd+O5dH5vYh4xjDH YkFAy5+xQfnmi8tj5oTosKgSGyuf3neTyKwJFA/w86EBtDPqpe3vfIP8qpnsG5Pq 36yVxtZZcL8kA9bk3I3ge21nVfj7obVVHn/IFN2BkyIFUBqwaYL6SEOV9BxbQLMY TJTRJb6s2/n+ASBxpS0dzZKdu248uFAaH8OIqgapCS8NpdFfrfuAITuWhWeg5sHJ +229C40xIyXFpqYoKmFPcUrDx84OHFkz07OkszN2d6Ser83og3S7kwfWAti+XE5F K/hmJaA36wM0l6o5zG9cVulm8XxzQlSJw4uCjxQ40zKZb3mlAagPGV/vwiROfY9X gxNgFyM0A5yZmyALY962pAaplB2RtaybO7bhcwUQJBIDcSn07X+JbT4wEYEK9lX/ iF3+ZkMPXyLeyTXqfGJdt7eNOK+yYWzQcKFmyUQEgd8jLHnER0R4rdgWxsued7NI zIAvLdkpjmk/fY37bz01InSrmhVA3rJDP1a6pKT5ElPx0cXsleZfydP3KZZOL5Tu f2k6bOee9io50fG8gFZ7X1RPXDKsC8vgqviD7c//9kstEofWidqQVC1YcWF7YPQp nmGEijWKJQqFdN50ox2UfUePMoVSkhiYdBHg3rnsXnSMWKGib80= =ta8x -----END PGP SIGNATURE-----