I managed to build a bridge between Termux and Minimalistic Text using Tasker. I use it to display the last 20 lines of the #termux irc channel as you can see in the picture. I've done it without having Tasker check a file every two minutes. The Task is directly called from the script.
This tutorial is not Termux specific and should work with any terminal emulator
Step 1: Creating the script
All you have to do is write your output to a file in
/sdcard/. In this example I am grabbing the last 20 lines of log of the #termux irc channel from my server.
while true; do # You can basically add your own commands here. They just have to write # their output to `/sdcard/widget` # For maximum battery and bandwidth efficiency tail and cut are # executed on the server # the cut command removes the timestamps # # for this to work you need to have placed your public key on the server. # Otherwise you will need to enter your password every two minutes ssh email@example.com "cat ~/.weechat/logs/irc.freenode.#termux.weechatlog |tail -n 20 | cut -c 21-">/sdcard/widget # This sends an Intent. This is how we'll call the Tasker task which # updates the widget. "net.dinglish.tasker" has to be there every # time for tasker to receive the intent. The last part is the name # of the intent which you can change if you want more than one. # This normally produces a bit of useless output. I am removing # #that with `>/dev/null` am broadcast -a net.dinglish.tasker.updatewidget --user 0 >/dev/null # sleep for 120 seconds. How often it should update the widget. sleep 120 done
If you run this it will download the last 20 lines of the log from a server, paste it into
/sdcard/widget and call Tasker with an Intent.
You should also create the file
/sdcard/widget now. Simply do
Step 2: Create a Tasker profile
- Create a new profile
- Choose "Event"
- In the "Select Event Category" dialog choose "System"->"Intent Received"
- As Action define
This profile will now be called whenever it recieves the "updatewidget" intent. This is a usefull way to extend the functionality of Termux. I also use it to kick of some Foldersync jobs from the terminal.
Step 3: Create the Task
- Tap "New Task" and give it a name
- Tap + to add a new Action
- Choose "File"->"Read File"
- Tap 🔍 and choose
- Under "To Var" enter
- Tap + again to add another new Action
- Choose "Plugin"->"Minimalistic Text"->"Minimalistic Text"
- Click the pen to edit the configuration
%Widgetfor both variable name and variable content
Step 4: Configure Minimalistic Text
- Add a Minimalistic Text widget to your homescreen
- Choose any preset
- In the "layout" tab remove remove all rows. Now you have a blank widget
- Add a new element with +
- Switch "Misc" Tab and tick "Locale variable"
- Tap "OK"
- Click on the new "Locale variable" element
- In the popup enter
%Widgetas a the "Variable name"
- "OK" and Save
Step 5: Run the script
Now you can run the script in Termux. Your widget should get updated right away.