aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcopy.sh96
1 files changed, 58 insertions, 38 deletions
diff --git a/copy.sh b/copy.sh
index 7975aea9..8a23336f 100755
--- a/copy.sh
+++ b/copy.sh
@@ -140,12 +140,16 @@ printf "\n%.0s" {1..1}
# Function to detect keyboard layout using localectl or setxkbmap
detect_layout() {
- if which localectl >/dev/null 2>&1; then
- layout=$(localectl status --no-pager | grep 'X11 Layout' | awk '{print $3}')
- [ -n "$layout" ] && echo "$layout"
- elif which setxkbmap >/dev/null 2>&1; then
+ if command -v localectl >/dev/null 2>&1; then
+ layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}')
+ if [ -n "$layout" ]; then
+ echo "$layout"
+ fi
+ elif command -v setxkbmap >/dev/null 2>&1; then
layout=$(setxkbmap -query | grep layout | awk '{print $2}')
- [ -n "$layout" ] && echo "$layout"
+ if [ -n "$layout" ]; then
+ echo "$layout"
+ fi
fi
}
@@ -154,9 +158,8 @@ layout=$(detect_layout)
if [ "$layout" = "(unset)" ]; then
while true; do
- printf "\n"
-
- print_color "$WARNING" "
+ printf "\n%.0s" {1..1}
+ print_color $WARNING "
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
STOP AND READ
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
@@ -176,9 +179,9 @@ ${MAGENTA} NOTE:${RESET}
• You can also set more than 2 keyboard layouts
• For example: ${YELLOW}us, kr, gb, ru${RESET}
"
- printf "\n"
-
- printf "%s - Please enter the correct keyboard layout: " "$CAT"
+ printf "\n%.0s" {1..1}
+
+ echo -n "${CAT} - Please enter the correct keyboard layout: "
read new_layout
if [ -n "$new_layout" ]; then
@@ -190,17 +193,15 @@ ${MAGENTA} NOTE:${RESET}
done
fi
-printf "\n"
-printf "%s Detecting keyboard layout to prepare proper Hyprland Settings\n" "$NOTE"
+printf "${NOTE} Detecting keyboard layout to prepare proper Hyprland Settings\n"
# Prompt the user to confirm whether the detected layout is correct
while true; do
- printf "%s Current keyboard layout is %s%s%s\n" "$INFO" "$MAGENTA" "$layout" "$RESET"
-
- printf "%s Is this correct? [y/n] " "$CAT"
+ printf "${INFO} Current keyboard layout is ${MAGENTA}$layout${RESET}\n"
+ echo -n "${CAT} Is this correct? [y/n] "
read keyboard_layout
- case "$keyboard_layout" in
+ case $keyboard_layout in
[yY])
awk -v layout="$layout" '/kb_layout/ {$0 = " kb_layout = " layout} 1' config/hypr/UserConfigs/UserSettings.conf > temp.conf
mv temp.conf config/hypr/UserConfigs/UserSettings.conf
@@ -208,10 +209,8 @@ while true; do
echo "${NOTE} kb_layout ${MAGENTA}$layout${RESET} configured in settings." 2>&1 | tee -a "$LOG"
break ;;
[nN])
- printf "\n"
- printf "\n"
-
- print_color "$WARNING" "
+ printf "\n%.0s" {1..2}
+ print_color $WARNING "
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
STOP AND READ
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
@@ -231,9 +230,9 @@ ${MAGENTA} NOTE:${RESET}
• You can also set more than 2 keyboard layouts
• For example: ${YELLOW}us, kr, gb, ru${RESET}
"
- printf "\n"
-
- printf "%s - Please enter the correct keyboard layout: " "$CAT"
+ printf "\n%.0s" {1..1}
+
+ echo -n "${CAT} - Please enter the correct keyboard layout: "
read new_layout
awk -v new_layout="$new_layout" '/kb_layout/ {$0 = " kb_layout = " new_layout} 1' config/hypr/UserConfigs/UserSettings.conf > temp.conf
@@ -276,8 +275,9 @@ EDITOR_SET=0
# Check for neovim if installed
if command -v nvim &> /dev/null; then
printf "${INFO} ${MAGENTA}neovim${RESET} is detected as installed\n"
- read -p "${CAT} Do you want to make ${MAGENTA}neovim${RESET} the default editor? (y/N): " EDITOR_CHOICE
- if [[ "$EDITOR_CHOICE" == "y" ]]; then
+ echo -n "${CAT} Do you want to make ${MAGENTA}neovim${RESET} the default editor? (y/N): "
+ read EDITOR_CHOICE
+ if [[ "$EDITOR_CHOICE" == "y" || "$EDITOR_CHOICE" == "Y" ]]; then
update_editor "nvim"
EDITOR_SET=1
fi
@@ -288,8 +288,9 @@ printf "\n"
# Check for vim if installed, but only if neovim wasn't chosen
if [[ "$EDITOR_SET" -eq 0 ]] && command -v vim &> /dev/null; then
printf "${INFO} ${MAGENTA}vim${RESET} is detected as installed\n"
- read -p "${CAT} Do you want to make ${MAGENTA}vim${RESET} the default editor? (y/N): " EDITOR_CHOICE
- if [[ "$EDITOR_CHOICE" == "y" ]]; then
+ echo -n "${CAT} Do you want to make ${MAGENTA}vim${RESET} the default editor? (y/N): "
+ read EDITOR_CHOICE
+ if [[ "$EDITOR_CHOICE" == "y" || "$EDITOR_CHOICE" == "Y" ]]; then
update_editor "vim"
EDITOR_SET=1
fi
@@ -305,7 +306,9 @@ while true; do
echo "${MAGENTA}Select monitor resolution to properly configure appearance and fonts:"
echo "$YELLOW -- Enter 1. for monitor resolution less than 1440p (< 1440p)"
echo "$YELLOW -- Enter 2. for monitor resolution equal to or higher than 1440p (≥ 1440p)"
- read -p "$CAT Enter the number of your choice (1 or 2): " res_choice
+
+ echo -n "$CAT Enter the number of your choice (1 or 2): "
+ read res_choice
case $res_choice in
1)
@@ -351,7 +354,8 @@ printf "\n%.0s" {1..1}
# Ask whether to change to 12hr format
while true; do
echo -e "${NOTE} ${SKY_BLUE} By default, KooL's Dots are configured in 24H clock format."
- read -p "$CAT Do you want to change to 12H (AM/PM) clock format? (y/n): " answer
+ echo -n "$CAT Do you want to change to 12H (AM/PM) clock format? (y/n): "
+ read answer
# Convert the answer to lowercase for comparison
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
@@ -435,14 +439,20 @@ printf "\n%.0s" {1..1}
echo "${NOTE} ${SKY_BLUE}By default, Rainbow Borders animation is enabled"
echo "${WARN} However, this uses a bit more CPU and Memory resources."
-read -p "${CAT} Do you want to disable Rainbow Borders animation? (y/N): " border_choice
+# Ask whether to disable Rainbow Borders animation
+echo -n "${CAT} Do you want to disable Rainbow Borders animation? (y/N): "
+read border_choice
+
+# Check user's choice
if [[ "$border_choice" =~ ^[Yy]$ ]]; then
+ # Disable Rainbow Borders
mv config/hypr/UserScripts/RainbowBorders.sh config/hypr/UserScripts/RainbowBorders.bak.sh
+ # Comment out the exec-once and animation lines
sed -i '/exec-once = \$UserScripts\/RainbowBorders.sh/s/^/#/' config/hypr/UserConfigs/Startup_Apps.conf
sed -i '/^[[:space:]]*animation = borderangle, 1, 180, liner, loop/s/^/#/' config/hypr/UserConfigs/UserAnimations.conf
- echo "${OK} Rainbow borders is now disabled." 2>&1 | tee -a "$LOG"
+ echo "${OK} Rainbow borders are now disabled." 2>&1 | tee -a "$LOG"
else
echo "${NOTE} No changes made. Rainbow borders remain enabled." 2>&1 | tee -a "$LOG"
fi
@@ -473,7 +483,9 @@ for DIR2 in $DIRS; do
if [ -d "$DIRPATH" ]; then
while true; do
printf "\n${INFO} Found ${YELLOW}$DIR2${RESET} config found in ~/.config/\n"
- read -p "${CAT} Do you want to replace ${YELLOW}$DIR2${RESET} config? (y/n): " DIR1_CHOICE
+ echo -n "${CAT} Do you want to replace ${YELLOW}$DIR2${RESET} config? (y/n): "
+ read DIR1_CHOICE
+
case "$DIR1_CHOICE" in
[Yy]* )
BACKUP_DIR=$(get_backup_dirname)
@@ -528,7 +540,9 @@ DIRW="waybar"
DIRPATHw="$HOME/.config/$DIRW"
if [ -d "$DIRPATHw" ]; then
while true; do
- read -p "${CAT} Do you want to replace ${YELLOW}$DIRW${RESET} config? (y/n): " DIR1_CHOICE
+ echo -n "${CAT} Do you want to replace ${YELLOW}$DIRW${RESET} config? (y/n): "
+ read DIR1_CHOICE
+
case "$DIR1_CHOICE" in
[Yy]* )
BACKUP_DIR=$(get_backup_dirname)
@@ -745,7 +759,8 @@ if [ -d "$BACKUP_DIR_PATH" ]; then
BACKUP_FILE="$BACKUP_DIR_PATH/$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 ${YELLOW}$FILE_NAME${RESET} from backup? (y/N): " file_restore
+ echo -n "${CAT} Do you want to restore ${YELLOW}$FILE_NAME${RESET} from backup? (y/N): "
+ read file_restore
if [[ "$file_restore" == [Yy]* ]]; then
if cp "$BACKUP_FILE" "$DIRPATH/UserConfigs/$FILE_NAME"; then
@@ -781,7 +796,9 @@ if [ -d "$BACKUP_DIR_PATH_S" ]; then
if [ -f "$BACKUP_SCRIPT" ]; then
printf "\n${INFO} Found ${YELLOW}$SCRIPT_NAME${RESET} in hypr backup...\n"
- read -p "${CAT} Do you want to restore ${YELLOW}$SCRIPT_NAME${RESET} from backup? (y/N): " script_restore
+ echo -n "${CAT} Do you want to restore ${YELLOW}$SCRIPT_NAME${RESET} from backup? (y/N): "
+ read script_restore
+
if [[ "$script_restore" == [Yy]* ]]; then
if cp "$BACKUP_SCRIPT" "$DIRSHPATH/UserScripts/$SCRIPT_NAME"; then
echo "${OK} - $SCRIPT_NAME restored!" 2>&1 | tee -a "$LOG"
@@ -816,7 +833,8 @@ if [ -d "$BACKUP_DIR_PATH_F" ]; then
if [ -f "$BACKUP_FILE" ]; then
echo -e "\n${INFO} Found ${YELLOW}$FILE_RESTORE${RESET} in hypr backup..."
- read -p "${CAT} Do you want to restore ${YELLOW}$FILE_RESTORE${RESET} from backup? (y/N): " file2restore
+ echo -n "${CAT} Do you want to restore ${YELLOW}$FILE_RESTORE${RESET} from backup? (y/N): "
+ read file2restore
if [[ "$file2restore" == [Yy]* ]]; then
if cp "$BACKUP_FILE" "$DIRPATH/$FILE_RESTORE"; then
@@ -987,7 +1005,9 @@ cleanup_backups() {
echo " - ${BACKUP##*/}"
done
- read -p "${CAT} Do you want to delete the older backups of ${YELLOW}${DIR##*/}${RESET} and keep the latest backup only? (y/N): " back_choice
+ echo -n "${CAT} Do you want to delete the older backups of ${YELLOW}${DIR##*/}${RESET} and keep the latest backup only? (y/N): "
+ read back_choice
+
if [[ "$back_choice" == [Yy]* ]]; then
# Sort backups by modification time
latest_backup="${BACKUP_DIRS[0]}"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage