Termux:Widget - How to create tasks for it?
i found this page on the wiki - https://wiki.termux.com/wiki/Termux:Widget which leads to this github page - https://github.com/termux/termux-widget which has this section in the README for Creating and Modifying Scripts - https://github.com/termux/termux-widget?tab=readme-ov-file#Creating-And-Modifying-Scripts but there appears to be no instructions on what goes in the script? Do i need to use Termux:GUI commands to create a UI? I have tried to do something simple like python -c "print('hello')" inside a file called ~/.shortcuts/test and then run test in the Termux:Widget app, but i don't see any output. i'm taken to the running Termux session app. Could someone please point me at some documentation for these scripts inside Termux:Widget? TIA
GitHub
GitHub - termux/termux-widget: Termux add-on app which adds shortcu...
Termux add-on app which adds shortcuts to commands on the home screen. - termux/termux-widget
GitHub
GitHub - termux/termux-widget: Termux add-on app which adds shortcu...
Termux add-on app which adds shortcuts to commands on the home screen. - termux/termux-widget
9 Replies
its whatever stuff inside .shortcuts, as long its an executable. you can use bash script, or symbolic link to an executable.
on your test, the command is executed, and exited after it done, so you might not see the output.
so i have just created a text file called ~/.shortcuts/test and the contents of test is:
python -c "print('hello')"
do i need to convert this into a bash script with a shebang? #!/bin/bash at the top? should i also chmod +x ~/.shortcuts/test ? if i want to see output from my command do i need to create a GUI using the Termux:GUI plugin?
i not familiar with python script, you might need use different shebang, yes you need chmod +x it, and no you don't need termux:GUI, widget will just open an session on termux running your script.
ok thanks let me try that
hmmm that didn't work. i added #!/bin/bash to the top of the script and did a chmod +x test. i also created another echo.sh:
#!/bin/bash
echo "Testing"
and did a chmod +x echo.sh
and then refreshed the Widget app and ran echo.sh. I don't get any errors, and the tasks appear to run, except it switches me to the already running Termux session, and there is no output from these scripts in the console
Solution
try adding sleep after echo
yeah that worked. so does that mean if i want to run a command and view the results or output of the command, i need to put some kind of sleep, or prompt for input to hold the output console?
yes ig, it sometimes have a prompt to exit, but im not sure how to trigger it.
ok thanks a lot for your help!
i have a question about Termux:Tasker, should i start a separate post for that?
yupr