termux / termux-widget

Termux add-on app which adds shortcuts to commands on the home screen.
https://f-droid.org/en/packages/com.termux.widget
Other
966 stars 111 forks source link

Feature request: Have a widget that shows the output of a command #29

Open sweenu opened 5 years ago

sweenu commented 5 years ago

I'd love to have the possibility to have widgets that executes a command every x seconds (chosen by user) and displays the output in the widget area!

Anyways, just discovered Termux, it's awesome, great work :)

PawelSuwinski commented 4 years ago

Just use watch for that, for example:

cat << EOT > ~/watch.sh
#!/bin/bash
watch -n "\${0##*_}" "\$(basename \${0%_*})"
EOT
chmod +x ~/watch.sh  

and every symlink to that script appended with '_n' will exec your script (if available in PATH) with name of simlink without ending '_n' in name on every n seconds.

Ex. ln -s ~/watch.sh ~/.shortcuts/my_task.sh_10

will run my_task.sh on every 10sek :).

zeonin commented 4 years ago

I think the more important part would be having the widget output be more dynamic. TBH, it would be very useful to have something like termux-dialog that could output to an Android widget that would also allow callbacks to a script or something.

Maybe even make it a bit like dmenu:

ls * | termux-widget <widget_number> | command here

or have a configuration dialog for termux-widget prompting for a script to run to generate widget entries and another script to run when one is selected.

bitcoinmeetups commented 3 years ago

Mm. I second this. This would be very useful. I guess Google corporate policy does not allow keyboard input for widgets. But being able to have the output of running scripts in a real widget would also be so useful.

ghost commented 3 years ago

I guess Google corporate policy does not allow keyboard input for widgets.

I guess SDK does not implement this. Widgets are basically just a clickable picture (complex layouts are also possible, but interaction is limited anyway) on the launcher screen. It also has limits on content update period.

RalfWerner commented 3 years ago

@bitcoinmeetups in 39 is an example that changes the widget tables (unfortunately only with reload). On some devices, Termux as a PiP without float is no problem Examples

tathastu871 commented 1 year ago

Maybe a resizable pop up supportint graphical display of output -> using scripts in .tasks folder -> widget to run script in background -> when cliked on widget again if script is already running then display popup showing live output or error -> if script not already running then run it normally (maybe live output directlt or from logged file using tail -n1)

Same as above but instead of widget using dynamic shortcut feature of termux

eg i have curl/wget script. script is written such yhat everythimg is silenced only the progress bar is shown in stdout. want to run script in background via wifget and keep checkimg stdout for progress bar

Check: https://play.google.com/store/apps/details?id=com.binarysmith.webclipwidget.ad

make two widgets 1-> to run script 2-> to display live text using id of 2nd we send text to it and using activity manager execute scheduled refresh of 2nd widget so kind of live update is displayed

Any help with such kind of setup

gardockt commented 12 months ago

Termux offers a way to create widgets through Termux:GUI app - sadly, it cannot be installed as of now.

To overcome this issue, I created my own widget that displays output of a command, refreshing itself every 15 minutes. Admittedly, it is quite limited, but works well for basic use cases - I've been successfully using it for a while, and I hope that other people find it useful as well.

bitcoinmeetups commented 12 months ago

Termux offers a way to create widgets through Termux:GUI app - sadly, it cannot be installed as of now.

To overcome this issue, I created my own widget that displays output of a command, refreshing itself every 15 minutes. Admittedly, it is quite limited, but works well for basic use cases - I've been successfully using it for a while, and I hope that other people find it useful as well.

I want to test it. Can you please add a link to an APK version at the front page of your repo? This maximizes the number of new users.

gardockt commented 12 months ago

Termux offers a way to create widgets through Termux:GUI app - sadly, it cannot be installed as of now. To overcome this issue, I created my own widget that displays output of a command, refreshing itself every 15 minutes. Admittedly, it is quite limited, but works well for basic use cases - I've been successfully using it for a while, and I hope that other people find it useful as well.

I want to test it. Can you please add a link to an APK version at the front page of your repo? This maximizes the number of new users.

APK is available in the Releases tab. Thanks for the suggestion though, I may add a link inside README later.

EDIT: At the time of writing this, Codeberg seems to be down, but GitHub mirror is also available: Repository | Releases

bitcoinmeetups commented 11 months ago

Termux offers a way to create widgets through Termux:GUI app - sadly, it cannot be installed as of now. To overcome this issue, I created my own widget that displays output of a command, refreshing itself every 15 minutes. Admittedly, it is quite limited, but works well for basic use cases - I've been successfully using it for a while, and I hope that other people find it useful as well.

I want to test it. Can you please add a link to an APK version at the front page of your repo? This maximizes the number of new users.

APK is available in the Releases tab. Thanks for the suggestion though, I may add a link inside README later.

EDIT: At the time of writing this, Codeberg seems to be down, but GitHub mirror is also available: Repository | Releases

Tried to install the app. Widget shows nothing, even though permissions have been enabled. Test command was ping bing.com

gardockt commented 11 months ago

Termux offers a way to create widgets through Termux:GUI app - sadly, it cannot be installed as of now. To overcome this issue, I created my own widget that displays output of a command, refreshing itself every 15 minutes. Admittedly, it is quite limited, but works well for basic use cases - I've been successfully using it for a while, and I hope that other people find it useful as well.

I want to test it. Can you please add a link to an APK version at the front page of your repo? This maximizes the number of new users.

APK is available in the Releases tab. Thanks for the suggestion though, I may add a link inside README later. EDIT: At the time of writing this, Codeberg seems to be down, but GitHub mirror is also available: Repository | Releases

Tried to install the app. Widget shows nothing, even though permissions have been enabled. Test command was ping bing.com

This is because the widget displays the output only after the command has finished - ping by default runs indefinitely, so the output is never shown. To fix this, pass the number of pings as an argument, for example ping -c 4 bing.com.

I cannot display the output while the command is running, and this is caused by Android security model - for more information, see "No session display, only output" part of "Limitations" section inside README.

bitcoinmeetups commented 11 months ago

Tried again using both ping -c 4 reddit.com and echo hello. Unfortunately neither displayed anything. Android 9. Not the latest Termux either.

gardockt commented 11 months ago

Tried again using both ping -c 4 reddit.com and echo hello. Unfortunately neither displayed anything. Android 9. Not the latest Termux either.

That's weird, since I managed to set it up both on my phone (also running Android 9) and virtual machines (including Android 9). Thank you for the mention about outdated Termux, this might be the culprit.

Two things you can check:

If that also did not help, then I'm out of ideas.

ghost commented 1 month ago

Termux:API has now termux-job-scheduler. I'm outputing job results into the text files. Having an widget to display configured file path(s) content would be great.