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

Task executes asynchronously if runInTerminal == true #39

Closed
xalexalex opened this issue Feb 2, 2021 · 4 comments
Closed

Task executes asynchronously if runInTerminal == true #39

xalexalex opened this issue Feb 2, 2021 · 4 comments

Comments

@xalexalex
Copy link

For tasks where runInTerminal == false, Tasker waits for the task to end (or for the timeout to elapse) before going on to the next action. This is also what I expected with runInTerminal == true, but what happens instead is that the task continues immediately. See attached video where Flash "Outside" happens as soon as the terminal is launched.

Not sure whether this is a bug report or feature request. If this behavior is unintended, then it's a bug report. I think, however, that the most user-friendly (and least surprising) thing to do, would be to add an option to wait (or not) for the termux task to finish before running the next action, regardless of runInTerminal.

Also pinging #16 which is related.

@agnostic-apollo
Copy link
Member

This is expected behaviour currently as mentioned in README

Execute in a terminal session toggle defines whether the commands will be run in the background or in a foreground terminal session.

If the toggle is enabled, a new terminal session will open up automatically in the foreground and commands will be run inside it. Result of commands is not returned to the plugin host app.

For BackgroundJobs, the stdout and stderr is captured in variables and can easily be returned to the plugin host app, but for foreground terminal session commands, those are sent to the terminal view.

However, exit code is still available when terminal sessions close, which can likely be sent back to the plugin host app, would require some work of course in termux-app, specially with linking sessions with their respective execution intents. And an addition of a Wait for commands to end toggle if Execute in a terminal session toggle is enabled in termux-tasker.

It might also be possible to capture stdout and stderr in variables and also sent them to the terminal view, but would require looking into.

@xalexalex
Copy link
Author

Okay, got it.
So definitely not a bug, but a feature request. Perhaps one thing we could do is be a bit more clear regarding the fact that the foreground terminal session runs independently from the tasker task, which continues immediately. I'd read the documentation but it is not explicit, and perhaps even a bit misleading ("run in background" stops the tasker task, whereas "run in foreground" runs asynchronously while the task continues).
Do you prefer to keep the issue open as a feature request? Otherwise I'll close it.
Thanks!

@agnostic-apollo
Copy link
Member

I agree, should make it more clear.

Leave it open, me or someone else would get to it. The termux-app android-10 branch may also require merging with master, so big changes in master before that would cause problems.

agnostic-apollo added a commit to agnostic-apollo/termux-tasker that referenced this issue Sep 11, 2021
Previously configured actions will behave the same, i.e wait for only background commands. For new or edited actions, the `Wait for result for commands` toggle value will be used to decide whether to wait for result of commands. It will apply to both foreground session and background commands.

Note that for foreground commands, only the session transcript is returned which will contain both `stdout` and `stderr` combined in `%stdout` variable, basically anything sent to the the pseudo terminal `/dev/pts`, including `PS1` prefixes for interactive sessions.

For foreground commands that exited with failure will require `termux-app` version `>=0.118` for sessions to automatically close without waiting for user to press enter as per termux/termux-app@162a430b.

Closes termux#39
@agnostic-apollo
Copy link
Member

Closed by fecba50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants