aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Williams <don.e.williams@gmail.com>2026-01-12 10:12:20 -0500
committerDon Williams <don.e.williams@gmail.com>2026-01-12 10:12:20 -0500
commita988f706e0080cde8aad3966948ac68ea0075da7 (patch)
tree47a79ba7fc361dea1a42fcfd2b0749e9f45297c4
parent88029592bbee3d227e15500b13f3a01f8b095862 (diff)
Added update dotfiles option to men
On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: copy.sh modified: scripts/copy_menu.sh new file: scripts/lib_update.sh
-rwxr-xr-xcopy.sh14
-rwxr-xr-xscripts/copy_menu.sh13
-rw-r--r--scripts/lib_update.sh84
3 files changed, 107 insertions, 4 deletions
diff --git a/copy.sh b/copy.sh
index 8df2532d..def8b209 100755
--- a/copy.sh
+++ b/copy.sh
@@ -6,6 +6,7 @@
#
# Layout (high-level; future modularization targets):
# - Constants/colors, helper sourcing (copy_menu.sh, lib_backup.sh, lib_detect.sh, lib_prompts.sh, lib_apps.sh, lib_copy.sh).
+# - New update helper (lib_update.sh) provides menu-driven repo update: verifies Hyprland-Dots root, stashes changes, git pull, logs, summarizes, waits for keypress.
# - Version helpers and CLI parsing (install/upgrade/express).
# - Safety checks (non-root), banners/notices.
# - Environment/distro checks and warnings.
@@ -57,6 +58,7 @@ DETECT_HELPER="$SCRIPT_DIR/scripts/lib_detect.sh"
PROMPTS_HELPER="$SCRIPT_DIR/scripts/lib_prompts.sh"
APPS_HELPER="$SCRIPT_DIR/scripts/lib_apps.sh"
COPY_HELPER="$SCRIPT_DIR/scripts/lib_copy.sh"
+UPDATE_HELPER="$SCRIPT_DIR/scripts/lib_update.sh"
if [ -f "$MENU_HELPER" ]; then
# shellcheck source=./scripts/copy_menu.sh
. "$MENU_HELPER"
@@ -96,6 +98,13 @@ else
echo "${ERROR} Copy helper not found at $COPY_HELPER. Exiting."
exit 1
fi
+if [ -f "$UPDATE_HELPER" ]; then
+ # shellcheck source=./scripts/lib_update.sh
+ . "$UPDATE_HELPER"
+else
+ echo "${ERROR} Update helper not found at $UPDATE_HELPER. Exiting."
+ exit 1
+fi
version_gte() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ]
@@ -193,6 +202,11 @@ if [ -z "$RUN_MODE" ]; then
UPGRADE_MODE=1
EXPRESS_MODE=1
;;
+ update)
+ run_repo_update "$SCRIPT_DIR"
+ # After update, continue showing the menu without exiting
+ continue
+ ;;
quit)
echo "${NOTE} Exiting per user selection."
exit 0
diff --git a/scripts/copy_menu.sh b/scripts/copy_menu.sh
index 18482b18..78fb4070 100755
--- a/scripts/copy_menu.sh
+++ b/scripts/copy_menu.sh
@@ -12,11 +12,13 @@ show_copy_menu() {
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"
if [ "$express_supported" -ne 1 ]; then
express_body="xpress - Requires dots >= ${MIN_EXPRESS_VERSION}"
@@ -29,6 +31,7 @@ show_copy_menu() {
"$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
@@ -40,15 +43,17 @@ show_copy_menu() {
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]: "
+ 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) choice="$express_tag"; break ;;
- 4) choice="$quit_tag"; break ;;
- *) echo "Invalid selection. Please choose 1-4." ;;
+ 4) choice="$update_tag"; break ;;
+ 5) choice="$quit_tag"; break ;;
+ *) echo "Invalid selection. Please choose 1-5." ;;
esac
done
fi
diff --git a/scripts/lib_update.sh b/scripts/lib_update.sh
new file mode 100644
index 00000000..0a70dff0
--- /dev/null
+++ b/scripts/lib_update.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+# run_repo_update
+# Arguments:
+# $1 - expected repository root (typically SCRIPT_DIR from copy.sh)
+# Behavior:
+# * Verifies the script is executed from Hyprland-Dots root.
+# * Stashes local changes (including untracked), pulls latest changes.
+# * Shows progress, reports errors, and summarizes results.
+# * Waits for user input before returning control to caller.
+run_repo_update() {
+ local repo_dir="${1:-$(pwd)}"
+ local expected_name="Hyprland-Dots"
+ local log_dir="$repo_dir/Copy-Logs"
+ local log_file="$log_dir/update-$(date +%d-%H%M%S)_git.log"
+
+ mkdir -p "$log_dir"
+
+ echo "${INFO} Starting repository update..." | tee -a "$log_file"
+
+ if [ ! -d "$repo_dir" ] || [ "$(basename "$repo_dir")" != "$expected_name" ]; then
+ echo "${ERROR} This helper must be run from the $expected_name directory. Current: $(pwd)" | tee -a "$log_file"
+ read -n1 -s -r -p "Press any key to return to the menu..."
+ echo
+ return 1
+ fi
+
+ if [ "$PWD" != "$repo_dir" ]; then
+ echo "${INFO} Changing directory to $repo_dir" | tee -a "$log_file"
+ cd "$repo_dir" || {
+ echo "${ERROR} Failed to change directory to $repo_dir" | tee -a "$log_file"
+ read -n1 -s -r -p "Press any key to return to the menu..."
+ echo
+ return 1
+ }
+ fi
+
+ local head_before stash_msg pull_status=0
+ head_before=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
+
+ echo "${INFO} Checking working tree..." | tee -a "$log_file"
+ if git diff --quiet && git diff --cached --quiet; then
+ stash_msg="No local changes; no stash created."
+ echo "${NOTE} $stash_msg" | tee -a "$log_file"
+ else
+ echo "${INFO} Stashing local changes (tracked + untracked)..." | tee -a "$log_file"
+ if stash_output=$(git stash push -u 2>&1); then
+ stash_msg="Created stash: $(echo "$stash_output" | head -n1)"
+ echo "${OK} $stash_msg" | tee -a "$log_file"
+ else
+ echo "${ERROR} git stash failed. Details:" | tee -a "$log_file"
+ echo "$stash_output" | tee -a "$log_file"
+ read -n1 -s -r -p "Press any key to return to the menu..."
+ echo
+ return 1
+ fi
+ fi
+
+ echo "${INFO} Pulling latest changes..." | tee -a "$log_file"
+ if git pull --ff-only 2>&1 | tee -a "$log_file"; then
+ pull_status=0
+ echo "${OK} Repository updated successfully." | tee -a "$log_file"
+ else
+ pull_status=$?
+ echo "${ERROR} git pull failed (exit $pull_status)." | tee -a "$log_file"
+ fi
+
+ local head_after
+ head_after=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
+
+ echo "----------------------------------------" | tee -a "$log_file"
+ echo "Summary:" | tee -a "$log_file"
+ echo " Repo : $repo_dir" | tee -a "$log_file"
+ echo " HEAD before : $head_before" | tee -a "$log_file"
+ echo " HEAD after : $head_after" | tee -a "$log_file"
+ echo " Stash : $stash_msg" | tee -a "$log_file"
+ echo " Pull status : $( [ $pull_status -eq 0 ] && echo success || echo failure )" | tee -a "$log_file"
+ echo "----------------------------------------" | tee -a "$log_file"
+
+ read -n1 -s -r -p "Press any key to return to the main menu..."
+ echo
+
+ return $pull_status
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage