Skip to content

Commit

Permalink
Update LinuxDroidmenu.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanVBW authored Dec 14, 2024
1 parent ba0b456 commit 2231275
Showing 1 changed file with 41 additions and 34 deletions.
75 changes: 41 additions & 34 deletions LinuxDroidmenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,56 @@ echo -e "\033[96m| 🌐Site:- AryanVBW.github.io |\033[0m"
echo -e "\033[96m| 💖Instagram:- Aryan_Technolog1es |\033[0m";
echo -e "\033[96m+===================================================+\033[0m";

echo -e "\e[1m\e[32mWelcome to the LinuxDroid!\e[0m"
declare -a os_list=()
# Color codes for a visually appealing welcome message
green='\033[0;32m'
reset='\033[0m'

# Find and extract OS names
# Clear the terminal for a clean start (optional)
clear

echo -e "${green}Welcome to the LinuxDroid!${reset}"
echo

# Find and extract OS names (using a regular expression)
os_list=()
for file in start-*.sh; do
os_name=$(echo "$file" | sed 's/start-\(.*\)\.sh/\1/')
os_list+=("$os_name")
os_name=${file##start-} # Extract OS name using parameter expansion
os_name=${os_name%.*} # Remove ".sh" extension
os_list+=("$os_name")
done

# Add "Termux" option
os_list+=("Termux")

# Display OS options
# Display OS options with clear numbering
echo "Available operating systems:"
for ((i=0; i<${#os_list[@]}; i++)); do
echo "$((i+1)). ${os_list[i]}"
printf "%3d. %s\n" $((i+1)) "${os_list[i]}"
done

# Prompt user for OS choice and handle invalid input
read -p "Enter the number of the OS you want to run (or 0 to exit): " os_number

while [[ ! $os_number =~ ^[0-9]+$ ]]; do
echo "Invalid input. Please enter a valid number (0 to exit) or a number corresponding to an available OS."
read -p "Enter the number of the OS you want to run (or 0 to exit): " os_number
done

# Prompt user for the number of the OS they want to run
read -p "Enter the number of the OS you want to run: " os_number

# Validate user input
if [ "$os_number" -ge 1 ] && [ "$os_number" -le "${#os_list[@]}" ]; then
selected_os="${os_list[$((os_number-1))]}"

# Display the selected number and OS name
echo "You selected OS number $os_number: $selected_os"

# Execute the corresponding script or exit for Termux
case $selected_os in
"Termux")
echo "Exiting Termux."
exit
;;
*)
script_name="start-$selected_os.sh"
if [ -f "$script_name" ]; then
echo "Executing ./$script_name"
./"$script_name"
else
echo "Script $script_name not found."
fi
;;
esac
# Validate user input and perform actions
if [[ $os_number -eq 0 ]]; then
echo "Exiting..."
exit 0
elif [[ $os_number -ge 1 && $os_number -le "${#os_list[@]}" ]]; then
selected_os="${os_list[$((os_number-1))]}"
script_name="start-$selected_os.sh"

if [[ -f "$script_name" ]]; then
echo -e "You selected OS number $os_number: $selected_os\n"
echo "Executing: ./$script_name"
./"$script_name" # Execute the script using source command
else
echo "Script '$script_name' not found."
fi
else
echo "Invalid input. Please enter a valid number."
echo "Invalid input. No matching OS found."
fi

0 comments on commit 2231275

Please sign in to comment.