termux-widget icon indicating copy to clipboard operation
termux-widget copied to clipboard

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

Open sweenu opened this issue 7 years ago • 14 comments

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 :)

sweenu avatar Dec 05 '18 09:12 sweenu

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 :).

PawelSuwinski avatar Feb 27 '20 10:02 PawelSuwinski

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.

zeonin avatar Apr 01 '20 18:04 zeonin

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.

621625 avatar Nov 28 '20 13:11 621625

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.

ghost avatar Nov 28 '20 14:11 ghost

@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

RalfWerner avatar Nov 28 '20 15:11 RalfWerner

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

tathastu871 avatar Mar 16 '23 10:03 tathastu871

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.

gardockt avatar Oct 08 '23 14:10 gardockt

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.

621625 avatar Oct 11 '23 07:10 621625

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

gardockt avatar Oct 11 '23 14:10 gardockt

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

621625 avatar Oct 13 '23 08:10 621625

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.

gardockt avatar Oct 13 '23 17:10 gardockt

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

621625 avatar Oct 14 '23 16:10 621625

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:

  • Is Termux version at least 0.109? I didn't check the minimum required version before, but the features I use were added in this version - earlier versions just fail silently.
  • Does the file $HOME/.termux/termux.properties contain uncommented line allow-external-apps = true? Termux should prompt for that on the first attempt to run a command.

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

gardockt avatar Oct 15 '23 17:10 gardockt