-
-
Notifications
You must be signed in to change notification settings - Fork 135
Description
Is your feature request related to a problem? Please describe.
Motivated by Termux integration support (and discussed in issue #501 ), I'd like a way for a Scripting Shortcuts to receive a File Sharing intent so that I can write scripts that process local files (or local file data). This feature would work in a manner similar to the Share files into a shortcut feature. That feature appears to be tied to the Response Handling of standard HTTPShortcuts.
Describe the solution you'd like
Personally, I'd like to use this feature in concert with Termux integration support, so that I can long tap on files and execute shell scripts, passing the file or file contents to the script. But I imagine there's still utility in being able to run arbitrary JavaScript code on files or file data.
I keep saying "file and file data or contents" because I'm not sure how android file sharing intents work--i don't know if it passes around a file pathspec, or the contents of the file. I suspect the latter, in order to avoid file permissions problems.
Assuming that's the case, it would be convenient if the new feature could include the ability to write the data to a temporary file. I can imagine this being either explicit in the shortcut definition (with a check box indicating that the data should be written out to a file) or implicit (availability of JavaScript functions that can read the data as if it were on standard input then write to a file.) I like the latter because it gives the shortcut author the option of writing to a file or keeping the file data in buffer memory. It also lets the author handle cleanup of the temporary file.
In my motivating use case, I'd write the data to temporary file, then utilize the runTermuxCommand function to pass the temp file to a shell script. Then I'd delete the temp file.
Actually, if there's a way to pipe data to the standard input of a shell script, I can see preferring that over temp files in some circumstances, but I don't know if that's technically possible, and even if it is, that would be an additional feature request.
Describe alternatives you've considered
Termux also supports handling of file sharing intents as described here. It's a bit awkward because it pops up an Edit dialog, and causes all shared files to be written into a specific folder. Furthermore, it's severely limited in that it will only run a single, pre-determined shell script (or symlink to preferred editor). So there's no way to define several different scripts/Shortcuts simultaneously. It's really only intended to be used to run a text editor.
Thanks for the consideration!