From 6b0a0531ceefbe6ea868f46e91ed24ce03dd5ea7 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sat, 21 Sep 2024 17:07:22 +0900 Subject: cleaned up copy.sh --- copy.sh | 107 +++++++++++++++++++++++++--------------------------------------- 1 file changed, 42 insertions(+), 65 deletions(-) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index 36f53e06..e6348d4e 100755 --- a/copy.sh +++ b/copy.sh @@ -2,7 +2,6 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ # clear - wallpaper=$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified waybar_style="$HOME/.config/waybar/style/[Dark] Latte-Wallust combined.css" waybar_config="$HOME/.config/waybar/configs/[TOP] Default_v4" @@ -20,7 +19,6 @@ echo ' ╠╩╗│ ││ │║ ╠═╣└┬┘├─┘├┬┘│ echo ' ╩ ╩└─┘└─┘╩═╝ ╩ ╩ ┴ ┴ ┴└─┴─┘┴ ┴┘└┘─┴┘ ═╩╝└─┘ ┴ └─┘ ' printf "\n%.0s" {1..2} - # Set some colors for output messages OK="$(tput setaf 2)[OK]$(tput sgr0)" ERROR="$(tput setaf 1)[ERROR]$(tput sgr0)" @@ -33,7 +31,6 @@ YELLOW=$(tput setaf 3) BLUE=$(tput setaf 4) RESET=$(tput sgr0) - # Create Directory for Copy Logs if [ ! -d Copy-Logs ]; then mkdir Copy-Logs @@ -208,7 +205,6 @@ update_editor() { } EDITOR_SET=0 - # Check for neovim if installed if command -v nvim &> /dev/null; then printf "${INFO} ${ORANGE}neovim${RESET} is detected as installed\n" @@ -315,7 +311,6 @@ if [[ "$answer" == "y" ]]; then sed -i 's/^\s*text = cmd\[update:1000\] echo "\$(date +"%S")"/# &/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG" sed -i 's/^\(\s*\)# *text = cmd\[update:1000\] echo "\$(date +"%S %p")" #AM\/PM/\1 text = cmd\[update:1000\] echo "\$(date +"%S %p")" #AM\/PM/' config/hypr/hyprlock.conf 2>&1 | tee -a "$LOG" - # for SDDM (simple-sddm) sddm_folder="/usr/share/sddm/themes/simple-sddm" if [ -d "$sddm_folder" ]; then @@ -349,22 +344,15 @@ done printf "\n" -# Rainbow Borders # Check if the user wants to disable Rainbow borders -# Print message about Rainbow Borders printf "${ORANGE} By default, Rainbow Borders animation is enabled.\n" printf "${WARN} - However, this uses a bit more CPU and Memory resources.\n" -# Prompt user to disable Rainbow Borders read -p "${CAT} Do you want to disable Rainbow Borders animation? (Y/N): " border_choice if [[ "$border_choice" =~ ^[Yy]$ ]]; then - # Move RainbowBorders.sh script to backup location mv config/hypr/UserScripts/RainbowBorders.sh config/hypr/UserScripts/RainbowBorders.bak.sh - # Comment out the line exec-once = $UserScripts/RainbowBorders.sh & sed -i '/exec-once = \$UserScripts\/RainbowBorders.sh \&/s/^/#/' config/hypr/UserConfigs/Startup_Apps.conf - - # Comment out the line animation = borderangle, 1, 180, liner, loop sed -i '/ animation = borderangle, 1, 180, liner, loop/s/^/#/' config/hypr/UserConfigs/UserDecorAnimations.conf echo "${OK} Rainbow borders is now disabled." 2>&1 | tee -a "$LOG" @@ -383,7 +371,6 @@ get_backup_dirname() { echo "back-up_${timestamp}" } - printf "${INFO} - copying dotfiles ${BLUE}first${RESET} part\n" # Config directories which will ask the user whether to replace or not DIRS=" @@ -509,63 +496,57 @@ if [ ! -d "config" ]; then exit 1 fi -DIR="hypr" +DIRH="hypr" FILES_TO_RESTORE=( - "Monitors.conf" + "Monitors.conf" "Laptops.conf" "UserKeybinds.conf" - ) -for DIR_NAME in $DIR; do - DIRPATH=~/.config/"$DIR_NAME" +) + +DIRPATH=~/.config/"$DIRH" +# Backup the existing directory if it exists +if [ -d "$DIRPATH" ]; then + echo -e "${NOTE} - Config for $DIRH found, attempting to back up." + BACKUP_DIR=$(get_backup_dirname) - # Backup the existing directory if it exists - if [ -d "$DIRPATH" ]; then - echo -e "${NOTE} - Config for $DIR_NAME found, attempting to back up." - BACKUP_DIR=$(get_backup_dirname) - - # Backup the existing directory - mv "$DIRPATH" "$DIRPATH-backup-$BACKUP_DIR" 2>&1 | tee -a "$LOG" - if [ $? -eq 0 ]; then - echo -e "${NOTE} - Backed up $DIR_NAME to $DIRPATH-backup-$BACKUP_DIR." - else - echo "${ERROR} - Failed to back up ${ORANGE}$DIR_NAME${RESET}." - exit 1 - fi + mv "$DIRPATH" "$DIRPATH-backup-$BACKUP_DIR" 2>&1 | tee -a "$LOG" + if [ $? -eq 0 ]; then + echo -e "${NOTE} - Backed up $DIRH to $DIRPATH-backup-$BACKUP_DIR." + else + echo "${ERROR} - Failed to back up ${ORANGE}$DIRH${RESET}." + exit 1 fi - - # Copy the new config - if [ -d "config/$DIR_NAME" ]; then - cp -r "config/$DIR_NAME" ~/.config/"$DIR_NAME" 2>&1 | tee -a "$LOG" - if [ $? -eq 0 ]; then - echo "${OK} - Copy of config for ${ORANGE}$DIR_NAME${RESET} completed!" - - # Loop through the files to check and offer restoration - for FILE_NAME in "${FILES_TO_RESTORE[@]}"; do - BACKUP_FILE="$DIRPATH-backup-$BACKUP_DIR/UserConfigs/$FILE_NAME" - if [ -f "$BACKUP_FILE" ]; then - printf "\n" - echo -e "${INFO} Found ${YELLOW}$FILE_NAME${RESET} in hypr backup..." - read -p "${CAT} Do you want to restore ${ORANGE}$FILE_NAME${RESET} from backup? (y/n): " file_restore - if [[ "$file_restore" == [Yy]* ]]; then - cp "$BACKUP_FILE" ~/.config/"$DIR_NAME"/UserConfigs/"$FILE_NAME" && echo "${OK} - $FILE_NAME restored!" 2>&1 | tee -a "$LOG" - else - echo "${NOTE} - Skipped restoring $FILE_NAME." - fi - fi - done +fi - else - echo "${ERROR} - Failed to copy $DIR_NAME." - exit 1 - fi +# Copy the new config +if [ -d "config/$DIRH" ]; then + cp -r "config/$DIRH" "$DIRPATH" 2>&1 | tee -a "$LOG" + if [ $? -eq 0 ]; then + echo "${OK} - Copy of config for ${ORANGE}$DIRH${RESET} completed!" + + # Loop through files to check and offer restoration + for FILE_NAME in "${FILES_TO_RESTORE[@]}"; do + BACKUP_FILE="$DIRPATH-backup-$BACKUP_DIR/UserConfigs/$FILE_NAME" + if [ -f "$BACKUP_FILE" ]; then + printf "\n${INFO} Found ${YELLOW}$FILE_NAME${RESET} in hypr backup...\n" + read -p "${CAT} Do you want to restore ${ORANGE}$FILE_NAME${RESET} from backup? (y/n): " file_restore + if [[ "$file_restore" == [Yy]* ]]; then + cp "$BACKUP_FILE" "$DIRPATH/UserConfigs/$FILE_NAME" && echo "${OK} - $FILE_NAME restored!" 2>&1 | tee -a "$LOG" + else + echo "${NOTE} - Skipped restoring $FILE_NAME." + fi + fi + done else - echo "${ERROR} - Directory config/$DIR_NAME does not exist to copy." + echo "${ERROR} - Failed to copy $DIRH." exit 1 fi +else + echo "${ERROR} - Directory config/$DIRH does not exist to copy." + exit 1 +fi -done - -printf "\n" +printf "\n%.0s" {1..2} # copying Wallpapers mkdir -p ~/Pictures/wallpapers @@ -576,7 +557,6 @@ chmod +x ~/.config/hypr/scripts/* 2>&1 | tee -a "$LOG" chmod +x ~/.config/hypr/UserScripts/* 2>&1 | tee -a "$LOG" # Set executable for initial-boot.sh chmod +x ~/.config/hypr/initial-boot.sh 2>&1 | tee -a "$LOG" -printf "\n" # Detect machine type and set waybar configurations accordingly if hostnamectl | grep -q 'Chassis: desktop'; then @@ -689,19 +669,16 @@ cleanup_backups() { fi done } - # Execute the cleanup function cleanup_backups -printf "\n%.0s" {1..1} - # symlinks for waybar style ln -sf "$waybar_style" "$HOME/.config/waybar/style.css" && \ # initialize wallust to avoid config error on hyprland wallust run -s $wallpaper 2>&1 | tee -a "$LOG" -printf "\n%.0s" {1..2} +printf "\n%.0s" {1..4} printf "${OK} GREAT! KooL's Hyprland-Dots is now Loaded & Ready!!!" printf "\n%.0s" {1..1} printf "${ORANGE} BUT SUGGEST to logout and re-login or reboot to avoid anyissues\n\n" -- cgit v1.2.3