From 4406c93ac29b6f3986e1b65c33b8d431f41797a1 Mon Sep 17 00:00:00 2001 From: shynd Date: Thu, 20 Feb 2025 21:01:22 +0100 Subject: [PATCH] working on copy script --- copy.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/copy.sh b/copy.sh index f818c45..0384bde 100644 --- a/copy.sh +++ b/copy.sh @@ -122,4 +122,91 @@ if [ -d "$HOME/.icons/Bibata-Modern-Ice/hyprcursors" ]; then sed -i 's/^#env = HYPRCURSOR_SIZE,24/env = HYPRCURSOR_SIZE,24/' "$HYPRCURSOR_ENV_FILE" fi -printf "\n%.0s" {1..1} \ No newline at end of file +printf "\n%.0s" {1..1} + +# detect the current keyboard layout +layout=$(detect_layout) + +if [ "$layout" = "(unset)" ]; then + while true; do + printf "\n%.0s" {1..1} + print_color $WARNING " + █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ + STOP AND READ + █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ + + !!! IMPORTANT WARNING !!! + +the default keyboard layout could not be detected +you need to set it manually + + !!! WARNING !!! + +setting a wrong keyboard layout will cause Hyprland to crash +If you are not sure, just type ${YELLOW}us${RESET} +${SKYBLUE}you can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET} + +${MAGENTA} NOTE:${RESET} +• you can also set more than 2 keyboard layouts +• for example: ${YELLOW}us, kr, gb, no${RESET} +" + printf "\n%.0s" {1..1} + read -p "${CAT} - please enter the correct keyboard layout: " new_layout + + if [ -n "$new_layout" ]; then + layout="$new_layout" + break + else + echo "${CAT} please enter a keyboard layout." + fi + done +fi + +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 "${INFO} current keyboard layout is ${MAGENTA}$layout${RESET}\n" + read -p "${CAT} is this correct? [y/n] " keyboard_layout + + 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 + + echo "${NOTE} kb_layout ${MAGENTA}$layout${RESET} configured in settings" 2>&1 | tee -a "$LOG" + break ;; + [nN]) + printf: "\n%.0s" {1..2} + print_color $WARNING " + █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ + STOP AND READ + █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ + + !!! IMPORTANT WARNING !!! + +the default keyboard layout could not be detected +you need to set it Manually + + !!! WARNING !!! + +setting a wrong keyboard layout will cause hyprland to crash +if you are not sure, just type ${YELLOW}us${RESET} +${SKYBLUE}you can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET} + +${MAGENTA} NOTE:${RESET} +• you can also set more than 2 keyboard layouts +• for example: ${YELLOW}us, kr, gb, no${RESET} +" + printf "\n%.0s" {1..1} + + read -p "${CAT} - Please enter the correct keyboard layout: " new_layout + + awk -v new_layout="$new_layout" '/kb_layout/ {$0 = " kb_layout = " new_layout} 1' config/hypr/UserConfigs/UserSettings.conf > temp.conf + mv temp.conf config/hypr/UserConfigs/UserSettings.conf + echo "${OK} kb_layout $new_layout configured in settings." 2>&1 | tee -a "$LOG" + break ;; + *) + echo "${ERROR} Please enter either 'y' or 'n'." ;; + esac +done \ No newline at end of file