50. Project: Creating a Termux Utility Dashboard
Congratulations! You have covered installation, scripting, customization, and networking. This final lesson is a project that synthesizes your knowledge: creating a simple, interactive, colored management dashboard in Bash.
The Goal
Create a script (dashboard.sh) that presents a menu to the user, allowing them to choose common management tasks (Update, Cleanup, Check IP, Exit).
Required Skills Utilized:
- Functions (Lesson 31)
- Conditional Logic (
if/else) (Lesson 29) - Loops (
while) (Lesson 30) - Variables and Input/Output (
read,echo) (Lesson 28) - Package Management (
pkg) (Lesson 16) - Networking (
ip addrorping) (Lesson 41) - Customizing Output (ANSI Colors) (Lesson 39)
Script Snippet (Core Logic)
bash #!/bin/bash
ANSI Colors
RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color
function display_menu() { clear echo -e "${GREEN}--- Termux Dashboard --- " echo "1) Run Update & Upgrade" echo "2) Cleanup Dependencies (Autoremove)" echo "3) Check Local IP Address" echo -e "4) ${RED}Exit Dashboard${NC}" echo "--------------------------" }
while true; do display_menu read -p "Enter choice: " CHOICE
case $CHOICE in
1)
echo "Running package update..."
pkg update && pkg upgrade -y
read -p "Press Enter to continue..."
;;
2)
echo "Running cleanup..."
pkg autoremove -y
read -p "Press Enter to continue..."
;;
3)
echo "Current IP:";
ip a show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d '/' -f 1
read -p "Press Enter to continue..."
;;
4)
echo "Exiting Termux Dashboard. Goodbye!"
break
;;
*)
echo -e "${RED}Invalid option. Try again.${NC}"
sleep 1
;;
esac
done
To run: chmod +x dashboard.sh and ./dashboard.sh.
This project solidifies your understanding, demonstrating how to build interactive, powerful tools within the Termux environment.