From 0e0b842de5a2394c395c75fef1d50695dc366c6a Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sat, 21 Sep 2024 16:28:32 +0900 Subject: added userkeybinds to restore --- copy.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index c75137c4..d12d1cdc 100755 --- a/copy.sh +++ b/copy.sh @@ -501,7 +501,6 @@ done printf "\n" - printf "${INFO} - Copying dotfiles ${BLUE}hypr directory${RESET} part\n" # Check if the config directory exists @@ -514,6 +513,7 @@ DIR="hypr" FILES_TO_RESTORE=( "Monitors.conf" "Laptops.conf" + "UserKeybinds.conf" ) for DIR_NAME in $DIR; do DIRPATH=~/.config/"$DIR_NAME" @@ -543,15 +543,14 @@ for DIR_NAME in $DIR; do for FILE_NAME in "${FILES_TO_RESTORE[@]}"; do BACKUP_FILE="$DIRPATH-backup-$BACKUP_DIR/UserConfigs/$FILE_NAME" if [ -f "$BACKUP_FILE" ]; then - echo -e "${INFO} - Found in backup ${YELLOW}$FILE_NAME${RESET}..." + 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!" + 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 - else - echo "${NOTE} - No $FILE_NAME found in backup." fi done @@ -563,6 +562,7 @@ for DIR_NAME in $DIR; do echo "${ERROR} - Directory config/$DIR_NAME does not exist to copy." exit 1 fi + done printf "\n" -- cgit v1.2.3 From d171d5f00176a2fce23712258ec0874cbf51f401 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sat, 21 Sep 2024 16:51:44 +0900 Subject: Added USerKeybinds.conf to restore, added Clean up function of the configs --- copy.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index d12d1cdc..36f53e06 100755 --- a/copy.sh +++ b/copy.sh @@ -352,7 +352,7 @@ printf "\n" # Rainbow Borders # Check if the user wants to disable Rainbow borders # Print message about Rainbow Borders -printf "${INFO} - By default, Rainbow Borders animation is enabled.\n" +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 @@ -638,14 +638,70 @@ while true; do esac done +# CLeaning up of ~/.config/ backups +cleanup_backups() { + CONFIG_DIR=~/.config + BACKUP_PREFIX="-backup" + + # Loop through directories in ~/.config + for DIR in "$CONFIG_DIR"/*; do + if [ -d "$DIR" ]; then + BACKUP_DIRS=() + + # Check for backup directories + for BACKUP in "$DIR"$BACKUP_PREFIX*; do + if [ -d "$BACKUP" ]; then + BACKUP_DIRS+=("$BACKUP") + fi + done + + # If more than one backup found + if [ ${#BACKUP_DIRS[@]} -gt 1 ]; then + printf "\n\n ${INFO} Performing clean up for ${ORANGE}${DIR##*/}${RESET}\n" + + echo -e "${NOTE} Found multiple backups for: ${ORANGE}${DIR##*/}${RESET}" + echo "${YELLOW}Backups: ${RESET}" + + # List the backups + for BACKUP in "${BACKUP_DIRS[@]}"; do + echo " - ${BACKUP##*/}" + done + + read -p "${CAT} Do you want to delete the older backups of ${ORANGE}${DIR##*/}${RESET} and keep the latest backup only? (y/n): " back_choice + if [[ "$back_choice" == [Yy]* ]]; then + # Sort backups by modification time + latest_backup="${BACKUP_DIRS[0]}" + for BACKUP in "${BACKUP_DIRS[@]}"; do + if [ "$BACKUP" -nt "$latest_backup" ]; then + latest_backup="$BACKUP" + fi + done + + for BACKUP in "${BACKUP_DIRS[@]}"; do + if [ "$BACKUP" != "$latest_backup" ]; then + echo "Deleting: ${BACKUP##*/}" + rm -rf "$BACKUP" + fi + done + echo "Old backups of ${ORANGE}${DIR##*/}${RESET} deleted, keeping: ${YELLOW}${latest_backup##*/}${RESET}" + fi + fi + 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 "${OK} GREAT! KooL's Hyprland-Dots Loaded & Ready!!!\n\n\n" +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 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 From 6a18a2b5b9f1c6efd760ec9c85b61b44fc7a9096 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sat, 21 Sep 2024 19:51:42 +0900 Subject: minor tweak copy.sh --- copy.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index e6348d4e..05d3a8b7 100755 --- a/copy.sh +++ b/copy.sh @@ -675,6 +675,8 @@ cleanup_backups # symlinks for waybar style ln -sf "$waybar_style" "$HOME/.config/waybar/style.css" && \ +printf "\n%.0s" {1..2} + # initialize wallust to avoid config error on hyprland wallust run -s $wallpaper 2>&1 | tee -a "$LOG" -- cgit v1.2.3 From 4421b026d58214ecf8693030feefee054deb0e81 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sun, 22 Sep 2024 00:00:26 +0900 Subject: updated copy.sh --- copy.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index 05d3a8b7..8f44362d 100755 --- a/copy.sh +++ b/copy.sh @@ -589,16 +589,16 @@ while true; do [Yy]) echo "${NOTE} Downloading additional wallpapers..." if git clone "https://github.com/JaKooLit/Wallpaper-Bank.git"; then - echo "${NOTE} Wallpapers downloaded successfully." 2>&1 | tee -a "$LOG" + echo "${OK} Wallpapers downloaded successfully." 2>&1 | tee -a "$LOG" # Check if wallpapers directory exists and create it if not if [ ! -d ~/Pictures/wallpapers ]; then mkdir -p ~/Pictures/wallpapers - echo "${NOTE} Created wallpapers directory." 2>&1 | tee -a "$LOG" + echo "${OK} Created wallpapers directory." 2>&1 | tee -a "$LOG" fi if cp -R Wallpaper-Bank/wallpapers/* ~/Pictures/wallpapers/ >> "$LOG" 2>&1; then - echo "${NOTE} Wallpapers copied successfully." 2>&1 | tee -a "$LOG" + echo "${OK} Wallpapers copied successfully." 2>&1 | tee -a "$LOG" rm -rf Wallpaper-Bank 2>&1 # Remove cloned repository after copying wallpapers break else @@ -681,6 +681,6 @@ printf "\n%.0s" {1..2} wallust run -s $wallpaper 2>&1 | tee -a "$LOG" printf "\n%.0s" {1..4} -printf "${OK} GREAT! KooL's Hyprland-Dots is now Loaded & Ready!!!" +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" +printf "${ORANGE}HOWEVER I HIGHLY SUGGEST to logout and re-login or better reboot to avoid any issues\n\n" -- cgit v1.2.3