aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/copy_menu.sh
blob: 4784320564d8ebe08c78dc2e471be539759483f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# ==================================================
#  KoolDots (2026)
#  Project URL: https://github.com/LinuxBeginnings
#  License: GNU GPLv3
#  SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================

# 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 update_tag="Update"
  local quit_tag="Quit"

  local install_desc="Fresh copy"
  local upgrade_desc="Backups + prompts"
  local express_desc="Skips restores & wallpapers"
  local update_desc="Stash + git pull"
  local quit_desc="Exit without changes"

  local choice=""
  run_basic_menu() {
    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"
      if [ "$express_supported" -eq 1 ]; then
        printf "  3) Express - %s\n" "$express_desc"
      else
        printf "  3) Express - %s (disabled)\n" "$express_desc"
      fi
      printf "  4) Update  - %s\n" "$update_desc"
      printf "  5) Quit    - %s\n" "$quit_desc"
      printf "Enter choice [1-5]: "
      read -r text_choice
      case "$text_choice" in
      1) choice="$install_tag"; break ;;
      2) choice="$upgrade_tag"; break ;;
      3)
        if [ "$express_supported" -eq 1 ]; then
          choice="$express_tag"
          break
        else
          echo "Express is disabled on this system."
        fi
        ;;
      4) choice="$update_tag"; break ;;
      5) choice="$quit_tag"; break ;;
      *) echo "Invalid selection. Please choose 1-5." ;;
      esac
    done
  }

  if [ "$COPY_TUI_BACKEND" = "basic" ]; then
    run_basic_menu
    COPY_MENU_CHOICE="$choice"
    return 0
  fi

  # Fallback to whiptail if present
  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" \
      "$update_tag" "$update_desc" \
      "$quit_tag" "$quit_desc" 3>&1 1>&2 2>&3); then
      COPY_MENU_CHOICE="quit"
      return 1
    fi
  else
    # Plain-text fallback
    run_basic_menu
  fi

  # shellcheck disable=SC2034  # used by parent script after sourcing this file
  COPY_MENU_CHOICE="$choice"
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage