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

Disable "Task executed: NAME-OF-SCRIPT.sh" toast when running a task via widget #33

Closed
mwcarew opened this issue Feb 8, 2019 · 2 comments

Comments

@mwcarew
Copy link

mwcarew commented Feb 8, 2019

#!/bin/bash

SSID="$(termux-wifi-connectioninfo | jq -r .ssid)"

if [ $SSID = "blahblah"]; then
  termux-toast Pihole disabled successfully.
else
  termux-toast Not connected to home WiFi.
fi

I use toasts to get the results of my script, but termux-widget does a "Task executed: NAME-OF-SCRIPT.sh" toast first and I have to wait for that to disappear before seeing the results. Super minor issue but I'd love for it to be a hair faster and be able to disable that initial toast.

@mwcarew
Copy link
Author

mwcarew commented Feb 10, 2019

		Intent executeIntent = new Intent(TermuxWidgetProvider.ACTION_EXECUTE, scriptUri);
		executeIntent.setClassName("com.termux", TermuxWidgetProvider.TERMUX_SERVICE);
		if (clickedFile.getParentFile().getName().equals("tasks")) {
			executeIntent.putExtra("com.termux.execute.background", true);
			// Show feedback for executed background task.
			String message = "Task executed: " + clickedFile.getName();
			Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
			toast.setGravity(Gravity.CENTER, 0, 0);
			toast.show();
		}

I'm not familiar with Java but I see where the relevant code is in TermuxLaunchShortcutActivity.java. I like how the default behavior is to confirm the task has run.

I'm not sure how I'd change it myself if I wanted to add this feature. Maybe it could check if there are other termux-toasts in the clickedFile? Or the termux-toast syntax itself could have a flag that would disable the default toast?

@fornwall
Copy link
Member

fornwall commented Aug 4, 2019

Thanks for the suggestion!

As an easy fix I change the "Task executed" toast to be on the top of the screen, to not block toasts from termux-toast (which are by default shown in the center of the screen).

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