Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to access Tasker variables from scripts #1

Closed
fornwall opened this issue Jan 9, 2017 · 8 comments

Comments

@fornwall
Copy link
Member

commented Jan 9, 2017

From https://www.reddit.com/r/tasker/comments/5mq7rc/psa_you_can_install_and_automate_things_like_curl/:

OK, so I'll just go with my own use-case as an example. I'm using Tasker to automatically write metadata to pictures as soon as I've taken them and exited the camera app. I do this by calling a Termux script from my Tasker task that runs perl exiftool [commands] /path/to/file.
In order for this to work, I obviously have to get the image file paths first of all. This is done by having Tasker read the camera folder and checking to see if there are image files that have been created since I last opened the camera app. The paths to these files are then stored in a local Tasker variable—let's say %paths.
Now I would like to pass this variable to the Termux script that I call at the end of my task in order to do something like perl exiftool [commands] $paths. What I have to do instead is write a text file in Tasker with the %paths variable and then have my Termux script read the information in that file to its own variable, which works but is kind of clunky.
I know I could rework my script to get the file paths directly in Termux, but it would be a lot more simple and versatile for a whole bunch of other use cases if it were possible to pass variables directly from Tasker.

@PacoBell

This comment has been minimized.

Copy link

commented Mar 2, 2017

I personally want to feed YouTube URLs into youtube-dl from the YouTube app Share to "Copy link" to clipboard. Tasker already has a monitor for the %CLIP variable. This would be so easy if it were possible.

@Neo-Oli

This comment has been minimized.

Copy link
Member

commented Mar 2, 2017

@PacoBell You can do something very similar to this without tasker. You can create a script at $HOME/bin/termux-url-opener containing the command:
youtube-dl $@

Then you can go to a youtube video and click the share button. Then you can, from the youtube app, share to "Termux".

This will automatically launch $HOME/bin/termux-url-opener http://youtube.com?v=xxxxxxxx

@PacoBell

This comment has been minimized.

Copy link

commented Mar 2, 2017

Awesome! I suppose I'd have to regex parse the URL in order to trigger different services depending on the domain.

@Neo-Oli

This comment has been minimized.

Copy link
Member

commented Mar 2, 2017

@PacoBell Yes. Or you can do what I do:
$HOME/bin/termux-url-opener

#!/data/data/com.termux/files/usr/bin/bash
cd ~/bin/
com=`ls --color=never url-*|fzf`
~/bin/$com $@

I then have various url-<name> scripts in $HOME/bin like
url-youtube-dl

youtube-dl $@

When I share I get this screen which lets me choose which script I want to run
screenshot_20170302-094514

@janru

This comment has been minimized.

Copy link

commented Mar 29, 2017

I'd like to pass a tasker variable to a termux script in the background. I assume, the solution above does not fit my needs, because it opens termux in the foreground, right?
let's say we have the script dosth.sh. Then I'd like to pass the string "myMessage" by executing '~/.termux/tasker/dosth.sh myMessage' which produces an error.
Could you please disable the check if the file "dosth.sh myMessage" exists? Or add a possibility to append parameters?

@TheNothingMan

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2017

Could you please disable the check if the file "dosth.sh myMessage" exists? Or add a possibility to append parameters?

I really would like to see that, too. Limiting Tasker to start scripts without parameters cuts down Tasker+Termux' possibilities.

From what I can see in the source code, all that is needed for this is adding the EXTRA_ARGUMENTS to the plugin setup, then add a PUT_EXTRA in the FireReceiver and send the extra to the TERMUX service.

EDIT: I had a close look on the source. It wasn't that easy, because Termux expects an array of arguments. However, I made it work as I would expect it, and created a pull request. Please have a look at it. This will lift the automation on the next level and make the money paid for the Tasker plugin well spent.

@TheNothingMan

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2017

While I am trying to be patient, I just have to ask: Will there be a version that contains the argument stuff at Google Play soon?
If there are any problems left with my code, I would be glad to see if I can help.

@fornwall

This comment has been minimized.

Copy link
Member Author

commented Sep 19, 2017

@TheNothingMan Thanks for your pull request - great work! I've just tagged the release and updated it to Google Play, so it should be available in a few hours as an update.

It should also appear on F-Droid within a day or so.

@fornwall fornwall closed this Sep 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.