From 3ebe8dc8917c409d0a6833bbe8163a9714c2d28b Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Sat, 25 Nov 2023 17:06:26 +0100 Subject: [PATCH] Added gum --- scripts/installupdates.sh | 56 +++++++++++++++++---------------------- scripts/snapshot.sh | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/scripts/installupdates.sh b/scripts/installupdates.sh index 265d97c..ddd2666 100755 --- a/scripts/installupdates.sh +++ b/scripts/installupdates.sh @@ -38,38 +38,32 @@ _isInstalledYay() { # Confirm Start # ------------------------------------------------------ -while true; do - read -p "DO YOU WANT TO START THE UPDATE NOW? (Yy/Nn): " yn - case $yn in - [Yy]* ) - echo "" - break;; - [Nn]* ) - exit; - break;; - * ) echo "Please answer yes or no.";; - esac -done +if gum confirm "DO YOU WANT TO START THE UPDATE NOW?" ;then + echo "Update started." +elif [ $? -eq 130 ]; then + exit 130 +else + echo "Update canceled." + exit; +fi +echo "" -if [[ $(_isInstalledYay "Timeshift") == 1 ]]; -then - while true; do - read -p "DO YOU WANT TO CREATE A SNAPSHOT? (Yy/Nn): " yn - case $yn in - [Yy]* ) - echo "" - read -p "Enter a comment for the snapshot: " c - sudo timeshift --create --comments "$c" - sudo timeshift --list - sudo grub-mkconfig -o /boot/grub/grub.cfg - echo "DONE. Snapshot $c created!" - echo "" - break;; - [Nn]* ) - break;; - * ) echo "Please answer yes or no.";; - esac - done +if [[ $(_isInstalledYay "Timeshift") == 1 ]] ;then + if gum confirm "DO YOU WANT TO CREATE A SNAPSHOT?" ;then + echo "" + c=$(gum input --placeholder "Enter a comment for the snapshot...") + sudo timeshift --create --comments "$c" + sudo timeshift --list + sudo grub-mkconfig -o /boot/grub/grub.cfg + echo "DONE. Snapshot $c created!" + echo "" + elif [ $? -eq 130 ]; then + echo "Snapshot canceled." + exit 130 + else + echo "Snapshot canceled." + fi + echo "" fi echo "-----------------------------------------------------" diff --git a/scripts/snapshot.sh b/scripts/snapshot.sh index 3996bff..1f6b128 100755 --- a/scripts/snapshot.sh +++ b/scripts/snapshot.sh @@ -9,7 +9,7 @@ # by Stephan Raabe (2023) # ----------------------------------------------------- -read -p "Enter a comment for the snapshot: " c +c=$(gum input --placeholder "Enter a comment for the snapshot...") sudo timeshift --create --comments "$c" sudo timeshift --list sudo grub-mkconfig -o /boot/grub/grub.cfg