From 30c453df3f5444d245b125252ebc284a558f9c06 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Tue, 21 Nov 2023 21:19:51 +0100 Subject: [PATCH] add gum confirm and profile selector --- .install/backup.sh | 2 ++ .install/bashrc.sh | 44 +++++++++++++------------------ .install/colors.sh | 10 ++++++-- .install/confirm-start.sh | 2 ++ .install/copy.sh | 39 ++++++++++++---------------- .install/disabledm.sh | 42 ++++++++++++++---------------- .install/excludes.txt | 1 + .install/install-packages.sh | 11 -------- .install/issue.sh | 2 ++ .install/profile.sh | 36 +++++--------------------- .install/required.sh | 7 ++--- .install/restore.sh | 50 +++++++++++++++++++----------------- .install/wallpaper.sh | 2 ++ install.sh | 26 +++++-------------- 14 files changed, 114 insertions(+), 160 deletions(-) mode change 100644 => 100755 .install/bashrc.sh mode change 100644 => 100755 .install/profile.sh diff --git a/.install/backup.sh b/.install/backup.sh index 5816ee1..cf0d794 100755 --- a/.install/backup.sh +++ b/.install/backup.sh @@ -44,6 +44,8 @@ echo -e "${NONE}" cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old echo "Existing .bashrc file found in homefolder. .bashrc-old created" fi + elif [ $? -eq 130 ]; then + exit 130 else echo "Backup skipped." fi diff --git a/.install/bashrc.sh b/.install/bashrc.sh old mode 100644 new mode 100755 index 1bffd22..7831bc9 --- a/.install/bashrc.sh +++ b/.install/bashrc.sh @@ -8,32 +8,24 @@ cat <<"EOF" | '_ \ / _` / __| '_ \| '__/ __| _| |_) | (_| \__ \ | | | | | (__ (_)_.__/ \__,_|___/_| |_|_| \___| - EOF echo -e "${NONE}" -while true; do - if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then - echo "PLEASE NOTE AGAIN: The script has detected an existing .bashrc file." - fi - if [ -f ~/dotfiles-versions/backups/$datets/.bashrc-old ]; then - echo "Backup is already available here ~/dotfiles-versions/backups/$datets/.bashrc-old" - fi - if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then - echo "" - echo "Do you want to replace your existing .bashrc file with the dotfiles .bashrc file?" - else - echo "" - echo "Do you want to install the dotfiles .bashrc file now?" - fi - read -p "Please confirm (Yy/Nn): " yn - case $yn in - [Yy]* ) - _installSymLink .bashrc ~/.bashrc ~/dotfiles/.bashrc ~/.bashrc - break;; - [Nn]* ) - echo "Installation of the .bashrc file skipped." - break;; - * ) echo "Please answer yes or no.";; - esac -done +if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then + echo "PLEASE NOTE AGAIN: The script has detected an existing .bashrc file." +fi +if [ -f ~/dotfiles-versions/backups/$datets/.bashrc-old ]; then + echo "Backup is already available here ~/dotfiles-versions/backups/$datets/.bashrc-old" +fi +if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then + bash_confirm="Do you want to replace your existing .bashrc file with the dotfiles .bashrc file?" +else + bash_confirm="Do you want to install the dotfiles .bashrc file now?" +fi +if gum confirm "$bash_confirm" ;then + _installSymLink .bashrc ~/.bashrc ~/dotfiles/.bashrc ~/.bashrc +elif [ $? -eq 130 ]; then + exit 130 +else + echo "Installation of the .bashrc file skipped." +fi echo "" diff --git a/.install/colors.sh b/.install/colors.sh index f84f878..9e228c8 100644 --- a/.install/colors.sh +++ b/.install/colors.sh @@ -1,6 +1,12 @@ -#!/bin/bash +#!/bin/sh RED='\033[0;31m' #'0;31' is Red GREEN='\033[0;32m' #'0;32' is Green YELLOW='\033[1;32m' #'1;32' is Yellow BLUE='\033[0;34m' #'0;34' is Blue -NONE='\033[0m' # NO COLOR \ No newline at end of file +NONE='\033[0m' # NO COLOR + +export GUM_CONFIRM_SELECTED_BACKGROUND="#FFF" +export GUM_CONFIRM_SELECTED_FOREGROUND="#000" + +export GUM_CONFIRM_UNSELECTED_BACKGROUND="#333" +export GUM_CONFIRM_UNSELECTED_FOREGROUND="#FFF" diff --git a/.install/confirm-start.sh b/.install/confirm-start.sh index b4f0f8c..a11daa6 100644 --- a/.install/confirm-start.sh +++ b/.install/confirm-start.sh @@ -17,6 +17,8 @@ fi if gum confirm "DO YOU WANT TO START THE INSTALLATION NOW?" ;then echo "Installation started." +elif [ $? -eq 130 ]; then + exit 130 else echo "Installation canceled." exit; diff --git a/.install/copy.sh b/.install/copy.sh index 91f605e..91afe41 100644 --- a/.install/copy.sh +++ b/.install/copy.sh @@ -46,26 +46,21 @@ if [ ! -d ~/dotfiles ]; then echo "" fi -while true; do - read -p "Do you want to install the prepared dotfiles now? (Yy/Nn): " yn - case $yn in - [Yy]* ) - if [ ! $mode == "dev" ]; then - echo "Copy started" - if [ ! -d ~/dotfiles ]; then - mkdir ~/dotfiles - echo "~/dotfiles folder created." - fi - rsync -a ~/dotfiles-versions/$version/ ~/dotfiles/ - echo "All files from ~/dotfiles-versions/$version/ to ~/dotfiles/ copied." - else - echo "Skipped: DEV MODE!" - fi - break;; - [Nn]* ) - exit - break;; - * ) echo "Please answer yes or no.";; - esac -done +if gum confirm "Do you want to install the prepared dotfiles now?" ;then + if [ ! $mode == "dev" ]; then + echo "Copy started" + if [ ! -d ~/dotfiles ]; then + mkdir ~/dotfiles + echo "~/dotfiles folder created." + fi + rsync -a ~/dotfiles-versions/$version/ ~/dotfiles/ + echo "All files from ~/dotfiles-versions/$version/ to ~/dotfiles/ copied." + else + echo "Skipped: DEV MODE!" + fi +elif [ $? -eq 130 ]; then + exit 130 +else + exit +fi echo "" diff --git a/.install/disabledm.sh b/.install/disabledm.sh index 5fc037c..49b5e42 100644 --- a/.install/disabledm.sh +++ b/.install/disabledm.sh @@ -5,12 +5,12 @@ disman=0 if [ -f /etc/systemd/system/display-manager.service ]; then echo -e "${GREEN}" cat <<"EOF" - ___ _ _ -|_ _|_ __ ___ _ __ ___ _ __| |_ __ _ _ __ | |_ - | || '_ ` _ \| '_ \ / _ \| '__| __/ _` | '_ \| __| - | || | | | | | |_) | (_) | | | || (_| | | | | |_ -|___|_| |_| |_| .__/ \___/|_| \__\__,_|_| |_|\__| - |_| + ____ _ _ __ __ +| _ \(_)___ _ __ | | __ _ _ _ | \/ | __ _ _ __ __ _ __ _ ___ _ __ +| | | | / __| '_ \| |/ _` | | | | | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \ '__| +| |_| | \__ \ |_) | | (_| | |_| | | | | | (_| | | | | (_| | (_| | __/ | +|____/|_|___/ .__/|_|\__,_|\__, | |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| + |_| |___/ |___/ EOF echo -e "${NONE}" @@ -31,23 +31,19 @@ echo -e "${NONE}" echo "But if you want to use the tty based (terminal) login instead, you can disable the display manager now." fi echo "" - while true; do - read -p "Do you want to deactive the current display manager (Yy/Nn): " yn - case $yn in - [Yy]* ) - if [ -f /etc/systemd/system/display-manager.service ]; then - sudo rm /etc/systemd/system/display-manager.service - echo "Current display manager removed." - fi - disman=1 - break;; - [Nn]* ) - echo "Disable display manager skipped." - echo "You can run ~/dotfiles/hypr/script/disablewm.sh at a later point of time if needed." - break;; - * ) echo "Please answer yes or no.";; - esac - done + + if gum confirm "Do you want to deactive the current display manager?" ;then + if [ -f /etc/systemd/system/display-manager.service ]; then + sudo rm /etc/systemd/system/display-manager.service + echo "Current display manager removed." + fi + disman=1 + elif [ $? -eq 130 ]; then + exit 130 + else + echo "Disable display manager skipped." + echo "You can run ~/dotfiles/hypr/script/disablewm.sh at a later point of time if needed." + fi echo "" else disman=1 diff --git a/.install/excludes.txt b/.install/excludes.txt index 6dd961b..12f5388 100644 --- a/.install/excludes.txt +++ b/.install/excludes.txt @@ -1,6 +1,7 @@ .gitignore .git .install +.dev README.md CHANGELOG LICENSE diff --git a/.install/install-packages.sh b/.install/install-packages.sh index cc91b60..c339fa9 100644 --- a/.install/install-packages.sh +++ b/.install/install-packages.sh @@ -1,17 +1,6 @@ # ------------------------------------------------------ # Install required packages # ------------------------------------------------------ -echo -e "${GREEN}" -cat <<"EOF" - ___ _ _ _ _ -|_ _|_ __ ___| |_ __ _| | | _ __ __ _ ___| | ____ _ __ _ ___ ___ - | || '_ \/ __| __/ _` | | | | '_ \ / _` |/ __| |/ / _` |/ _` |/ _ \/ __| - | || | | \__ \ || (_| | | | | |_) | (_| | (__| < (_| | (_| | __/\__ \ -|___|_| |_|___/\__\__,_|_|_| | .__/ \__,_|\___|_|\_\__,_|\__, |\___||___/ - |_| |___/ - -EOF -echo -e "${NONE}" _installPackagesPacman "${packagesPacman[@]}"; _installPackagesYay "${packagesYay[@]}"; echo "" \ No newline at end of file diff --git a/.install/issue.sh b/.install/issue.sh index 8a079e4..44894ff 100644 --- a/.install/issue.sh +++ b/.install/issue.sh @@ -16,6 +16,8 @@ EOF echo -e "${NONE}" if gum confirm "Do you want to install the custom tty login issue?" ;then sudo cp login/issue /etc/issue + elif [ $? -eq 130 ]; then + exit 130 else echo "Setup tty login skipped." fi diff --git a/.install/profile.sh b/.install/profile.sh old mode 100644 new mode 100755 index 7e82a64..894368b --- a/.install/profile.sh +++ b/.install/profile.sh @@ -12,32 +12,10 @@ cat <<"EOF" EOF echo -e "${NONE}" -echo "Please select the Desktop Profile for your installation:" -echo "1 - Hyprland" -echo "2 - Qtile" -echo "3 - All" -echo "Nn - Cancel" -echo "" -while true; do - read -p "PLEASE SELECT: " yn - case $yn in - [1]* ) - profile="Hyprland" - break;; - [2]* ) - profile="Qtile" - break;; - [3]* ) - profile="All" - break;; - [Nn]* ) - echo "Installation canceled." - exit; - break;; - * ) echo "Please answer yes or no.";; - esac -done -echo "" -echo "Installing profile $profile ..." -sleep 2 -echo "" \ No newline at end of file + +echo "SPACE = select/unselect a profile. RETURN = confirm. No selection = CANCEL" +profile=$(gum choose --no-limit --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " "Hyprland" "Qtile") +if [ -z $profile ] ;then + echo "No profile selected. Installation canceled." + exit +fi \ No newline at end of file diff --git a/.install/required.sh b/.install/required.sh index 819c51f..0390f66 100644 --- a/.install/required.sh +++ b/.install/required.sh @@ -2,6 +2,7 @@ # Check for required packages to run the installation # ------------------------------------------------------ -echo "Checking that rsync and gum is installed..." -_installPackagesPacman "rsync"; -_installPackagesPacman "gum"; \ No newline at end of file +echo "Checking that required packages for the installation are installed..." +echo "" +_installPackagesPacman "rsync" "gum"; +echo "" \ No newline at end of file diff --git a/.install/restore.sh b/.install/restore.sh index 2043462..589e68c 100644 --- a/.install/restore.sh +++ b/.install/restore.sh @@ -22,7 +22,7 @@ echo -e "${NONE}" if [ -f ~/dotfiles/.bashrc ]; then echo ".bashrc file: ~/dotfiles/.bashrc" fi - if [ $profile == "Hyprland" ] || [ $profile == "All" ]; then + if [[ $profile == *"Hyprland"* ]]; then if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then echo "Hyprland keyboard layout: ~/dotfiles/hypr/conf/keyboard.conf" fi @@ -33,38 +33,40 @@ echo -e "${NONE}" echo "Hyprland keybindings: ~/dotfiles/hypr/conf/keybindings.conf" fi fi - if [ $profile == "Qtile" ] || [ $profile == "All" ]; then + if [[ $profile == *"Qtile"* ]]; then if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then echo "Qtile keyboard layout: ~/dotfiles/qtile/conf/keyboard.py" fi fi echo "" if gum confirm "Do you want to restore the files now and use it on your new installation?" ;then - if [ -f ~/dotfiles/.bashrc ]; then - cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/ - echo ".bashrc restored!" + if [ -f ~/dotfiles/.bashrc ]; then + cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/ + echo ".bashrc restored!" + fi + if [[ $profile == *"Hyprland"* ]]; then + if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then + cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/ + echo "Hyprland keyboard.conf restored!" fi - if [ $profile == "Hyprland" ] || [ $profile == "All" ]; then - if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then - cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/ - echo "Hyprland keyboard.conf restored!" - fi - if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then - cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/ - echo "Hyprland monitor.conf restored!" - fi - if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then - cp ~/dotfiles/hypr/conf/keybindings.conf ~/dotfiles-versions/$version/hypr/conf/ - echo "Hyprland keybindings.conf restored!" - fi + if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then + cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/ + echo "Hyprland monitor.conf restored!" fi - if [ $profile == "Qtile" ] || [ $profile == "All" ]; then - if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then - cp ~/dotfiles/qtile/conf/keyboard.py ~/dotfiles-versions/$version/qtile/conf/ - echo "Qtile keyboard.py restored!" - fi + if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then + cp ~/dotfiles/hypr/conf/keybindings.conf ~/dotfiles-versions/$version/hypr/conf/ + echo "Hyprland keybindings.conf restored!" fi - restored=1 + fi + if [[ $profile == *"Qtile"* ]]; then + if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then + cp ~/dotfiles/qtile/conf/keyboard.py ~/dotfiles-versions/$version/qtile/conf/ + echo "Qtile keyboard.py restored!" + fi + fi + restored=1 + elif [ $? -eq 130 ]; then + exit 130 else echo "Restore skipped" fi diff --git a/.install/wallpaper.sh b/.install/wallpaper.sh index 99ec2e6..a0bce80 100644 --- a/.install/wallpaper.sh +++ b/.install/wallpaper.sh @@ -24,6 +24,8 @@ if [ ! -d ~/wallpaper ]; then fi cp ~/Downloads/wallpaper-main/* ~/wallpaper/ echo "Wallpapers frpm the repository installed successfully." + elif [ $? -eq 130 ]; then + exit 130 else if [ -d ~/wallpaper/ ]; then echo "wallpaper folder already exists." diff --git a/install.sh b/install.sh index 0e4587f..ddbc065 100755 --- a/install.sh +++ b/install.sh @@ -33,24 +33,14 @@ source .install/confirm-start.sh source .install/backup.sh source .install/preparation.sh source .install/profile.sh -if [ $profile == "Hyprland" ]; then - source .install/hyprland.sh -fi -if [ $profile == "Qtile" ]; then - source .install/qtile.sh -fi source .install/yay.sh -if [ $profile == "Hyprland" ]; then +if [[ $profile == *"Hyprland"* ]]; then + source .install/hyprland.sh source .install/hyprland-packages.sh source .install/install-packages.sh fi -if [ $profile == "Qtile" ]; then - source .install/qtile-packages.sh - source .install/install-packages.sh -fi -if [ $profile == "All" ]; then - source .install/hyprland-packages.sh - source .install/install-packages.sh +if [[ $profile == *"Qtile"* ]]; then + source .install/qtile.sh source .install/qtile-packages.sh source .install/install-packages.sh fi @@ -63,14 +53,10 @@ source .install/keyboard.sh source .install/copy.sh source .install/config-folder.sh source .install/init-pywal.sh -if [ $profile == "Hyprland" ]; then +if [[ $profile == *"Hyprland"* ]]; then source .install/hyprland-dotfiles.sh fi -if [ $profile == "Qtile" ]; then - source .install/qtile-dotfiles.sh -fi -if [ $profile == "All" ]; then - source .install/hyprland-dotfiles.sh +if [[ $profile == *"Qtile"* ]]; then source .install/qtile-dotfiles.sh fi source .install/bashrc.sh