From 09f5247792a687b37067b051c95f4a9e05334808 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Thu, 12 Jun 2025 16:45:35 +0100 Subject: [PATCH] Install.sh overhaul with a TUI --- install.sh | 139 ++++++++++++++++++++++++----------------------------- 1 file changed, 63 insertions(+), 76 deletions(-) diff --git a/install.sh b/install.sh index 9d19a58f..d22b638e 100755 --- a/install.sh +++ b/install.sh @@ -1,17 +1,48 @@ #! /bin/sh -# NOTE: Use `hyperfine` to benchmark - -# Colors -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -PURPLE='\033[0;35m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color +RED="\e[31m" +GREEN="\e[32m" +YELLOW="\e[33m" +MAGENTA="\e[35m" +CYAN="\e[36m" +BOLD="\e[1m" +NC="\e[0m" trap 'printf "${RED}install.sh interrupted.${NC}"; exit 1' INT TERM +testing_branch="trixie" + +window_height='15' +window_width='60' + +W_MAIN=$( + whiptail --notags --title "Trude's Dotfiles" \ + --cancel-button "Exit" \ + --menu "Main Menu" $window_height $window_width 3 \ + "install" "Install Dotfiles" \ + "reload" "Reload Configuration" \ + "update" "Update Debian" \ + 3>&1 1>&2 2>&3 +) + +if [ -z $W_MAIN ]; then + exit 1 +fi + +if [ $W_MAIN = "update" ]; then + ./scripts/update + exit 0 +fi + +if [ $W_MAIN = "install" ]; then + W_DEB_SOURCES=$(whiptail --notags --title "Debian Sources" \ + --cancel-button "Skip" \ + --menu "Choose your Debian source:" $window_height $window_width 2 \ + "stable" "Stable" \ + "testing" "Testing ($testing_branch)" \ + 3>&1 1>&2 2>&3) +fi + install_gnome_extension() { uuid="$1" @@ -40,22 +71,8 @@ install_gnome_extension() { fi } -# Flags -reload=false -for arg in "$@"; do - if [ "$arg" = "-r" ]; then - reload=true - fi - if [ "$arg" = "-h" ]; then - echo "Usage: $0 [-r][-h]" - echo " -r: Reload config" - echo " -h: Show help message" - exit 0 - fi -done - # Clone Dotfiles if not already present -if [ "$reload" = false ]; then +if [ $W_MAIN = "install" ]; then cd "$HOME/dotfiles" if [ "$(pwd)" != "$HOME/dotfiles" ]; then echo "${YELLOW}Cloning dotfiles repository...${NC}" @@ -82,27 +99,13 @@ fi mkdir -p "$HOME/dotfiles/logs" -echo "${CYAN}####################" -echo "#${PURPLE} Trude's Dotfiles${CYAN} #" -echo "####################" -./scripts/fetch -echo - -# Install Programs -if [ "$reload" = false ]; then - testing_branch="trixie" - echo "Debian Sources:" - echo "1) Stable" - echo "2) Testing ($testing_branch)" - echo "3) Skip ($(lsb_release -c -s))" - printf "Enter your choice: " - - while read -r REPLY; do - case $REPLY in - 1) - echo "${CYAN}Using Stable sources.${NC}" - sudo cp /etc/apt/sources.list /etc/apt/sources.list.bckp - sudo sh -c 'cat > /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list < /etc/apt/sources.list <