diff options
| author | Donald Williams <129223418+dwilliam62@users.noreply.github.com> | 2026-01-09 18:47:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-09 18:47:42 -0500 |
| commit | 46e342ceb3a2757554685853597e12a9e70427e0 (patch) | |
| tree | a65f6262c722762e06e4f5d158bdda29b01660ff | |
| parent | db41c69e3bf2396d7dcf56b2c6314b4078a61299 (diff) | |
Copy menu - 1st step in menu driven dot files install / upgrade process (#917)
* Phase 1 of creating TUI for copy.sh for installs and upgrades
On branch copy-menu
Changes to be committed:
modified: copy.sh
new file: scripts/copy_menu.sh
* Fixing formatting in copy-menu
On branch copy-menu
Your branch is up to date with 'origin/copy-menu'.
Changes to be committed:
modified: scripts/copy_menu.sh
* More formatting and color first letter as selectable option
On branch copy-menu
Your branch is up to date with 'origin/copy-menu'.
Changes to be committed:
modified: copy.sh
modified: scripts/copy_menu.sh
* Fixing syntax error
* Some whiptail versions don't support color
Added check before displaying colors
On branch copy-menu
Your branch is up to date with 'origin/copy-menu'.
Changes to be committed:
modified: scripts/copy_menu.sh
* fixing formatting
On branch copy-menu
Your branch is up to date with 'origin/copy-menu'.
Changes to be committed:
modified: scripts/copy_menu.sh
* More formatting for whiptail
* Formatting whiptail is so much fun
* Changed descrption to two lines
* Whiltail 4, human 0
* Whiltail 5, human 0 - shortened text
* Whiltail 6, human 1 - remove dup items
* Whiltail 6, human 2 - removed color highlight
| -rwxr-xr-x | copy.sh | 51 | ||||
| -rwxr-xr-x | scripts/copy_menu.sh | 58 |
2 files changed, 109 insertions, 0 deletions
@@ -23,6 +23,12 @@ BLUE="$(tput setaf 4)" SKY_BLUE="$(tput setaf 6)" RESET="$(tput sgr0)" MIN_EXPRESS_VERSION="2.3.18" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +MENU_HELPER="$SCRIPT_DIR/scripts/copy_menu.sh" +if [ -f "$MENU_HELPER" ]; then + # shellcheck source=./scripts/copy_menu.sh + . "$MENU_HELPER" +fi version_gte() { [ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ] @@ -60,15 +66,18 @@ EOF UPGRADE_MODE=0 EXPRESS_MODE=0 +RUN_MODE="" while [[ $# -gt 0 ]]; do case "$1" in --upgrade) UPGRADE_MODE=1 + RUN_MODE="upgrade" ;; --express-upgrade) UPGRADE_MODE=1 EXPRESS_MODE=1 + RUN_MODE="express" ;; -h | --help) print_usage @@ -90,6 +99,47 @@ fi if [ "$EXPRESS_MODE" -eq 1 ] && [ "$EXPRESS_SUPPORTED" -eq 0 ]; then echo "${WARN} Express upgrade requires installed dotfiles v${MIN_EXPRESS_VERSION} or newer. Falling back to standard upgrade." EXPRESS_MODE=0 + RUN_MODE="upgrade" +fi + +if [ -z "$RUN_MODE" ]; then + if declare -f show_copy_menu >/dev/null 2>&1; then + while [ -z "$RUN_MODE" ]; do + show_copy_menu "$EXPRESS_SUPPORTED" + choice_lower=$(echo "$COPY_MENU_CHOICE" | tr '[:upper:]' '[:lower:]') + case "$choice_lower" in + install) + RUN_MODE="install" + UPGRADE_MODE=0 + EXPRESS_MODE=0 + ;; + upgrade) + RUN_MODE="upgrade" + UPGRADE_MODE=1 + EXPRESS_MODE=0 + ;; + express) + if [ "$EXPRESS_SUPPORTED" -eq 0 ]; then + echo "${WARN} Express mode requires installed dotfiles v${MIN_EXPRESS_VERSION} or newer. Please choose another option." + continue + fi + RUN_MODE="express" + UPGRADE_MODE=1 + EXPRESS_MODE=1 + ;; + quit) + echo "${NOTE} Exiting per user selection." + exit 0 + ;; + *) + echo "${WARN} Invalid selection." + ;; + esac + done + else + echo "${NOTE} Menu helper not found; defaulting to install workflow." + RUN_MODE="install" + fi fi # Check if running as root. If root, script will exit @@ -154,6 +204,7 @@ LOG="Copy-Logs/install-$(date +%d-%H%M%S)_dotfiles.log" # update home directories xdg-user-dirs-update 2>&1 | tee -a "$LOG" || true +echo "${INFO} Selected workflow: ${RUN_MODE}" 2>&1 | tee -a "$LOG" if [ "$UPGRADE_MODE" -eq 1 ]; then echo "${INFO} Upgrade mode enabled." 2>&1 | tee -a "$LOG" fi diff --git a/scripts/copy_menu.sh b/scripts/copy_menu.sh new file mode 100755 index 00000000..18482b18 --- /dev/null +++ b/scripts/copy_menu.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# show_copy_menu +# Arguments: +# $1 - express_supported flag (1 if available, 0 otherwise) +# Sets global COPY_MENU_CHOICE to one of: install, upgrade, express, quit +show_copy_menu() { + local express_supported="${1:-0}" + local menu_title=" KooL's Hyprland Dotfiles " + local prompt="Select what you would like to do:" + + local install_tag="Install" + local upgrade_tag="Upgrade" + local express_tag="Express" + local quit_tag="Quit" + + local install_desc="Fresh copy" + local upgrade_desc="Backups + prompts" + local express_desc="Skips restores & wallpapers" + local quit_desc="Exit without changes" + if [ "$express_supported" -ne 1 ]; then + express_body="xpress - Requires dots >= ${MIN_EXPRESS_VERSION}" + fi + + local choice="" + + if command -v whiptail >/dev/null 2>&1; then + if ! choice=$(whiptail --title "$menu_title" --menu "$prompt" 17 60 8 \ + "$install_tag" "$install_desc" \ + "$upgrade_tag" "$upgrade_desc" \ + "$express_tag" "$express_desc" \ + "$quit_tag" "$quit_desc" 3>&1 1>&2 2>&3); then + COPY_MENU_CHOICE="quit" + return 1 + fi + else + while true; do + printf "\n%s\n" "$menu_title" + printf "%s\n" "$prompt" + printf " 1) Install - %s\n" "$install_desc" + printf " 2) Upgrade - %s\n" "$upgrade_desc" + printf " 3) Express - %s\n" "$express_desc" + printf " 4) Quit - %s\n" "$quit_desc" + printf "Enter choice [1-4]: " + read -r text_choice + case "$text_choice" in + 1) choice="$install_tag"; break ;; + 2) choice="$upgrade_tag"; break ;; + 3) choice="$express_tag"; break ;; + 4) choice="$quit_tag"; break ;; + *) echo "Invalid selection. Please choose 1-4." ;; + esac + done + fi + + # shellcheck disable=SC2034 # used by parent script after sourcing this file + COPY_MENU_CHOICE="$choice" +} |
