diff options
| author | Ja.KooLit <85185940+JaKooLit@users.noreply.github.com> | 2024-09-21 14:04:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-21 14:04:49 +0900 |
| commit | ff4950c490019459bc02908136e1edabe9156d83 (patch) | |
| tree | ca6fed7392bd6b7aae737a34d391182950adc302 | |
| parent | 2b715deacefc61247ca15ed8527730c0537407f1 (diff) | |
| parent | 4c2c3f777b0b5b9b79d59627268e1971444fa00c (diff) | |
Merge pull request #454 from JaKooLit/development
Added functionality to check if nvim or vim is installed and offer to set as default editor
| -rwxr-xr-x | copy.sh | 64 |
1 files changed, 48 insertions, 16 deletions
@@ -104,7 +104,7 @@ layout=$(detect_layout) if [ "$layout" = "(unset)" ]; then while true; do printf "\n%.0s" {1..1} -print_color $ORANGE " + print_color $ORANGE " █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ STOP AND READ █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ @@ -131,7 +131,7 @@ NOTE: layout="$new_layout" break else - echo "Please enter a keyboard layout." + echo "${CAT} Please enter a keyboard layout." fi done fi @@ -140,19 +140,20 @@ 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 - read -p "$ORANGE Current keyboard layout is: $layout ${CAT} Is this correct? [y/n] " confirm + printf "${NOTE} Current keyboard layout is ${ORANGE}$layout${RESET}\n" + read -p "${CAT} Is this correct? [y/n] " keyboard_layout - case $confirm in + case $keyboard_layout in [yY]) # If the detected layout is correct, update the 'kb_layout =' line in the file 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 $layout configured in settings. " 2>&1 | tee -a "$LOG" + echo "${NOTE} kb_layout ${ORANGE}$layout${RESET} configured in settings." 2>&1 | tee -a "$LOG" break ;; [nN]) printf "\n%.0s" {1..2} -print_color $ORANGE " + print_color $ORANGE " █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ STOP AND READ █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ @@ -172,17 +173,17 @@ NOTE: • You can also set more than 2 keyboard layouts • For example us, kr, gb, ru " - printf "\n%.0s" {1..1} - - read -p "${CAT} - Please enter the correct keyboard layout: " new_layout - - # Update the 'kb_layout =' line with the correct layout in the file - 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 "${NOTE} kb_layout $new_layout configured in settings." 2>&1 | tee -a "$LOG" - break ;; + printf "\n%.0s" {1..1} + + read -p "${CAT} - Please enter the correct keyboard layout: " new_layout + + # Update the 'kb_layout =' line with the correct layout in the file + 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 "${NOTE} kb_layout $new_layout configured in settings." 2>&1 | tee -a "$LOG" + break ;; *) - echo "${ERROR} Please enter either 'y' or 'n'." ;; + echo "${ERROR} Please enter either 'y' or 'n'." ;; esac done @@ -195,6 +196,37 @@ fi printf "\n" +# Checking if neovim or vim is installed and offer user if they want to make as default editor +# Function to modify the ENVariables.conf file +update_editor() { + local editor=$1 + sed -i "s/#env = EDITOR,.*/env = EDITOR,$editor #default editor/" config/hypr/UserConfigs/ENVariables.conf + echo "${OK} Default editor set to ${ORANGE}$editor${RESET}." 2>&1 | tee -a "$LOG" +} + +# Check for neovim if installed +if command -v nvim &> /dev/null; then + printf "${NOTE} ${ORANGE}neovim${RESET} is detected as installed\n" + read -p "${CAT} Do you want to make ${ORANGE}neovim${RESET} the default editor? (y/n): " EDITOR_CHOICE + if [[ "$EDITOR_CHOICE" == "y" ]]; then + update_editor "nvim" + exit 0 + fi +fi + +# Check for vim if installed +if command -v vim &> /dev/null; then + printf "${NOTE} ${ORANGE}vim${RESET} is detected as installed\n" + read -p "${CAT} Do you want to make ${ORANGE}vim${RESET} the default editor? (y/n): " EDITOR_CHOICE + if [[ "$EDITOR_CHOICE" == "y" ]]; then + update_editor "vim" + fi +else + echo "${ORANGE} Neither neovim nor vim is installed." +fi + +printf "\n" + # Action to do for better rofi and kitty appearance while true; do echo "$ORANGE Select monitor resolution for better config appearance and fonts:" |
