49. Termux Addons Overview: Termux:API, Widget, and Boot
Termux's core power is extended dramatically through specialized addons, which bridge the gap between the Linux shell and the Android OS features.
1. Termux:API
This addon allows Termux scripts to interact directly with Android APIs (GPS, camera, battery status, notifications).
Installation: Install the Termux:API app from F-Droid and the command-line utility inside Termux:
bash $ pkg install termux-api
Example Usage: Reading battery status in a script:
bash $ termux-battery-status
Outputs JSON data about the battery
Example Usage: Sending a notification from a script:
bash $ termux-notification --title "Script Done" --content "Task completed successfully."
2. Termux:Widget
This addon allows you to execute shell scripts directly from a shortcut on your Android home screen (widget).
- Scripts must be placed in
~/.shortcuts/. - This is the best way to manually trigger scheduled or automated tasks that don't need continuous background running.
3. Termux:Boot
If installed, Termux:Boot allows you to automatically run specific scripts when your Android device finishes booting up.
- Scripts are placed in
~/.termux/boot/. - Ideal for starting services like
sshdor long-running tasks as soon as the phone starts.