From 33f538966f6f9388654a4c170c7db8f118a34a38 Mon Sep 17 00:00:00 2001 From: PostCyberPunk Date: Thu, 4 Jan 2024 20:28:31 +0800 Subject: [PATCH 1/3] feat(preset):add preset for quick installlation check var exist before ask remove var add preset file add a question to check should use preset patch custom question fix blacklist nouveau name not clear fix input group var not clear fix pokemon var not clear add comment for preset var use preset env var before excute script add preset to script print preset info --- install-scripts/InputGroup.sh | 13 ++++++---- install-scripts/dotfiles.sh | 7 +++++- install-scripts/nvidia.sh | 9 +++++-- install-scripts/sddm.sh | 11 +++++++-- install-scripts/xdph.sh | 7 +++++- install-scripts/zsh.sh | 9 +++++-- install.sh | 45 +++++++++++++++++++++++++---------- preset.sh | 40 +++++++++++++++++++++++++++++++ 8 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 preset.sh diff --git a/install-scripts/InputGroup.sh b/install-scripts/InputGroup.sh index b98c995..e445d90 100755 --- a/install-scripts/InputGroup.sh +++ b/install-scripts/InputGroup.sh @@ -2,6 +2,9 @@ # 💫 https://github.com/JaKooLit 💫 # # Adding users into input group # +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## # Determine the directory where the script is located @@ -20,9 +23,11 @@ while true; do echo "${WARN} This script will add or remove your user from the 'input' group." echo "${NOTE} Please note that adding yourself to the 'input' group might be necessary for waybar keyboard-state functionality." - read -p "${YELLOW}Do you want to proceed? (y/n): ${RESET}" choice + if [[ -z $input_group_choid ]]; then + read -p "${YELLOW}Do you want to proceed? (y/n): ${RESET}" input_group_choid + fi - if [[ $choice == "y" || $choice == "Y" ]]; then + if [[ $input_group_choid == "y" || $input_group_choid == "Y" ]]; then # Check if the 'input' group exists if grep -q '^input:' /etc/group; then echo "${OK} 'input' group exists." @@ -41,7 +46,7 @@ while true; do # Log the addition of the user to the 'input' group echo "User added to 'input' group" >> "$LOG" break # Break out of the loop if 'yes' is chosen - elif [[ $choice == "n" || $choice == "N" ]]; then + elif [[ $input_group_choid == "n" || $input_group_choid == "N" ]]; then echo "${NOTE} No changes made. Exiting the script." break # Break out of the loop if 'no' is chosen else @@ -49,4 +54,4 @@ while true; do fi done -clear \ No newline at end of file +clear diff --git a/install-scripts/dotfiles.sh b/install-scripts/dotfiles.sh index 75576d6..bf492fb 100755 --- a/install-scripts/dotfiles.sh +++ b/install-scripts/dotfiles.sh @@ -1,6 +1,9 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # Hyprland-Dots to download from Releases # +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi ## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ## @@ -28,7 +31,9 @@ if [ -f Hyprland-Dots.tar.gz ]; then exit 0 else echo -e "${WARN} Hyprland-Dots.tar.gz is outdated (Existing version: $existing_version, Latest version: $latest_version)." - read -p "Do you want to upgrade to the latest version? (y/n): " upgrade_choice + if [[ -z $upgrade_choice ]]; then + read -p "Do you want to upgrade to the latest version? (y/n): " upgrade_choice + fi if [ "$upgrade_choice" = "y" ]; then echo -e "${NOTE} Proceeding to download the latest release." 2>&1 | tee -a "../Install-Logs/install-$(date +'%d-%H%M%S')_dotfiles.log" diff --git a/install-scripts/nvidia.sh b/install-scripts/nvidia.sh index 413fd7f..53afa12 100755 --- a/install-scripts/nvidia.sh +++ b/install-scripts/nvidia.sh @@ -1,6 +1,9 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # Nvidia Stuffs # +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi nvidia_pkg=( nvidia-dkms @@ -93,9 +96,11 @@ else fi # Blacklist nouveau -read -n1 -rep "${CAT} Would you like to blacklist nouveau? (y/n)" response + if [[ -z $blacklist_nouveau ]]; then + read -n1 -rep "${CAT} Would you like to blacklist nouveau? (y/n)" blacklist_nouveau + fi echo -if [[ $response =~ ^[Yy]$ ]]; then +if [[ $blacklist_nouveau =~ ^[Yy]$ ]]; then NOUVEAU="/etc/modprobe.d/nouveau.conf" if [ -f "$NOUVEAU" ]; then printf "${OK} Seems like nouveau is already blacklisted..moving on.\n" diff --git a/install-scripts/sddm.sh b/install-scripts/sddm.sh index a72e95e..57cd408 100755 --- a/install-scripts/sddm.sh +++ b/install-scripts/sddm.sh @@ -1,6 +1,9 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # SDDM Log-in Manager # +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi sddm=( qt5-graphicaleffects @@ -28,7 +31,9 @@ LOG="Install-Logs/install-$(date +%d-%H%M%S)_sddm.log" # Check if SDDM is already installed if pacman -Qs sddm > /dev/null; then # Prompt user to manually install sddm-git to remove SDDM - read -n1 -rep "SDDM is already installed. Would you like to manually install sddm-git to remove it? This requires manual intervention. (y/n)" manual_install_sddm + if [[ -z $manual_install_sddm ]]; then + read -n1 -rep "SDDM is already installed. Would you like to manually install sddm-git to remove it? This requires manual intervention. (y/n)" manual_install_sddm + fi echo if [[ $manual_install_sddm =~ ^[Yy]$ ]]; then $ISAUR -S sddm-git 2>&1 | tee -a "$LOG" @@ -65,7 +70,9 @@ sudo cp assets/hyprland.desktop "$wayland_sessions_dir/" 2>&1 | tee -a "$LOG" # SDDM-themes valid_input=false while [ "$valid_input" != true ]; do - read -n 1 -r -p "${CAT} OPTIONAL - Would you like to install SDDM themes? (y/n)" install_sddm_theme + if [[ -z $install_sddm_theme ]]; then + read -n 1 -r -p "${CAT} OPTIONAL - Would you like to install SDDM themes? (y/n)" install_sddm_theme + fi if [[ $install_sddm_theme =~ ^[Yy]$ ]]; then printf "\n%s - Installing Simple SDDM Theme\n" "${NOTE}" diff --git a/install-scripts/xdph.sh b/install-scripts/xdph.sh index 3a2ee1a..68e546a 100755 --- a/install-scripts/xdph.sh +++ b/install-scripts/xdph.sh @@ -1,6 +1,9 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # XDG-Desktop-Portals # +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi xdg=( xdg-desktop-portal-hyprland @@ -37,7 +40,9 @@ sleep 1 printf "\n" printf "${NOTE} XDG-desktop-portal-KDE & GNOME (if installed) should be manually disabled or removed! I can't remove it... sorry...\n" while true; do - read -rp "${CAT} Would you like to try to remove other XDG-Desktop-Portal-Implementations? (y/n) " XDPH1 + if [[ -z $XDPH1 ]]; then + read -rp "${CAT} Would you like to try to remove other XDG-Desktop-Portal-Implementations? (y/n) " XDPH1 + fi echo sleep 1 diff --git a/install-scripts/zsh.sh b/install-scripts/zsh.sh index cbbf853..8c49778 100755 --- a/install-scripts/zsh.sh +++ b/install-scripts/zsh.sh @@ -1,6 +1,9 @@ #!/bin/bash # 💫 https://github.com/JaKooLit 💫 # # zsh and oh my zsh including pokemon-color-scripts# +if [[ $USE_PRESET = [Yy] ]]; then + source ./preset.sh +fi zsh=( zsh @@ -23,8 +26,10 @@ LOG="Install-Logs/install-$(date +%d-%H%M%S)_zsh.log" ## Optional Pokemon color scripts while true; do - read -p "${CAT} OPTIONAL - Do you want to add Pokemon color scripts? (y/n): " choice - case "$choice" in + if [[ -z $pokemon_choice ]]; then + read -p "${CAT} OPTIONAL - Do you want to add Pokemon color scripts? (y/n): " pokemon_choice + fi + case "$pokemon_choice" in [Yy]*) zsh+=('pokemon-colorscripts-git') sed -i '/#pokemon-colorscripts --no-title -s -r/s/^#//' assets/.zshrc diff --git a/install.sh b/install.sh index 26c95e4..b9d444e 100755 --- a/install.sh +++ b/install.sh @@ -25,12 +25,17 @@ echo "$(tput setaf 3)NOTE: If you are installing on a VM, ensure to enable 3D ac echo read -p "$(tput setaf 6)Would you like to proceed? (y/n): $(tput sgr0)" proceed +read -p "$(tput setaf 6)Would you like to preset? (y/n): $(tput sgr0)" use_preset + if [ "$proceed" != "y" ]; then echo "Installation aborted." exit 1 fi +if [[ $use_preset = [Yy] ]]; then + source ./preset.sh +fi # Create Directory for Install Logs if [ ! -d Install-Logs ]; then @@ -59,22 +64,32 @@ colorize_prompt() { LOG="install-$(date +%d-%H%M%S).log" # Initialize variables to store user responses -aur_helper="" -bluetooth="" -dots="" -gtk_themes="" -nvidia="" -rog="" -sddm="" -thunar="" -xdph="" -zsh="" +# aur_helper="" +# bluetooth="" +# dots="" +# gtk_themes="" +# nvidia="" +# rog="" +# sddm="" +# thunar="" +# xdph="" +# zsh="" # Define the directory where your scripts are located script_directory=install-scripts # Function to ask a yes/no question and set the response in a variable ask_yes_no() { + if [[ ! -z "${!2}" ]]; then + echo "$(colorize_prompt "$CAT" "$1 (Preset): ${!2}")" + if [[ "${!2}" = [Yy] ]]; then + return 0 + else + return 1 + fi + else + eval "$2=''" + fi while true; do read -p "$(colorize_prompt "$CAT" "$1 (y/n): ")" choice case "$choice" in @@ -91,6 +106,12 @@ ask_custom_option() { local valid_options="$2" local response_var="$3" + if [[ ! -z "${!3}" ]]; then + return 0 + else + eval "$3=''" + fi + while true; do read -p "$(colorize_prompt "$CAT" "$prompt ($valid_options): ")" choice if [[ " $valid_options " == *" $choice "* ]]; then @@ -108,7 +129,7 @@ execute_script() { if [ -f "$script_path" ]; then chmod +x "$script_path" if [ -x "$script_path" ]; then - "$script_path" + env USE_PRESET=$use_preset "$script_path" else echo "Failed to make script '$script' executable." fi @@ -129,8 +150,6 @@ ask_yes_no "-Do you want to configure Bluetooth?" bluetooth printf "\n" ask_yes_no "-Do you want to install Thunar file manager?" thunar printf "\n" -ask_yes_no "-Install & configure SDDM log-in Manager w/ (Optional) SDDM Theme?" sddm -printf "\n" ask_yes_no "-Install XDG-DESKTOP-PORTAL-HYPRLAND? (For proper Screen Share ie OBS)" xdph printf "\n" ask_yes_no "-Install zsh, oh-my-zsh & (Optional) pokemon-colorscripts?" zsh diff --git a/preset.sh b/preset.sh new file mode 100644 index 0000000..43a53a1 --- /dev/null +++ b/preset.sh @@ -0,0 +1,40 @@ +############ !!!!!Make sure you use the right answer or it may failed +### +### -Type AUR helper +### yay or paru +aur_helper="yay" +############ use : "Y" or "N" +###-Do you have any nvidia gpu in your system? +nvidia="Y" +###-Install GTK themes (required for Dark/Light function)? +gtk_themes="Y" +###-Do you want to configure Bluetooth? +bluetooth="Y" +###-Do you want to install Thunar file manager? +thunar="Y" +###-Do you want to install Thunar file manager? +sddm="Y" +###-Install XDG-DESKTOP-PORTAL-HYPRLAND? (For proper Screen Share ie OBS) +xdph="Y" +###-Install zsh, oh-my-zsh & (Optional) pokemon-colorscripts? +zsh="N" +###-Installing in a Asus ROG Laptops? +rog="N" +###-Do you want to download pre-configured Hyprland dotfiles? +dots="N" + +### Would you like to blacklist nouveau? (y/n) +blacklist_nouveau="Y" +### Do you want to upgrade to the latest version? (y/n): +upgrade_choice="Y" +### Would you like to try to remove other XDG-Desktop-Portal-Implementations? (y/n) +XDPH1="Y" +### SDDM is already installed. Would you like to manually install sddm-git to remove it? This requires manual intervention. (y/n) +manual_install_sddm="N" +### OPTIONAL - Would you like to install SDDM themes? (y/n) +install_sddm_theme="Y" +### " This script will add or remove your user from the 'input' group." +### " Please note that adding yourself to the 'input' group might be necessary for waybar keyboard-state functionality." +input_group_choid="Y" +### OPTIONAL - Do you want to add Pokemon color scripts? (y/n): +pokemon_choice="N" From fc31b99d98e03b82e5d702b81db4e698ac2c08c9 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" Date: Fri, 5 Jan 2024 22:22:33 +0900 Subject: [PATCH 2/3] Update install.sh Added some notes regarding Use of Preset --- install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b9d444e..3a024d8 100755 --- a/install.sh +++ b/install.sh @@ -25,8 +25,13 @@ echo "$(tput setaf 3)NOTE: If you are installing on a VM, ensure to enable 3D ac echo read -p "$(tput setaf 6)Would you like to proceed? (y/n): $(tput sgr0)" proceed -read -p "$(tput setaf 6)Would you like to preset? (y/n): $(tput sgr0)" use_preset +printf "\n%.0s" {1..2} +echo "$(tput bold)$(tput setaf 7)Choose Y to use preset ONLY once you reviewed, updated or updated the preset.sh $(tput sgr0)" +echo "$(tput bold)$(tput setaf 7)If you are not sure what to do, choose N in the "Use Preset Settings" question $(tput sgr0)" +printf "\n%.0s" {1..1} +read -p "$(tput setaf 6)Would you like to Use Preset Settings? (y/n): $(tput sgr0)" use_preset +printf "\n%.0s" {1..3} if [ "$proceed" != "y" ]; then echo "Installation aborted." From 6066051354366d6ed9729a8523ef2d633ef43520 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" Date: Fri, 5 Jan 2024 22:24:52 +0900 Subject: [PATCH 3/3] Update preset.sh Changed some preset settings in case Users accidentally choose Y in using preset with even reviewing it --- preset.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/preset.sh b/preset.sh index 43a53a1..ced849d 100644 --- a/preset.sh +++ b/preset.sh @@ -17,11 +17,11 @@ sddm="Y" ###-Install XDG-DESKTOP-PORTAL-HYPRLAND? (For proper Screen Share ie OBS) xdph="Y" ###-Install zsh, oh-my-zsh & (Optional) pokemon-colorscripts? -zsh="N" +zsh="Y" ###-Installing in a Asus ROG Laptops? rog="N" ###-Do you want to download pre-configured Hyprland dotfiles? -dots="N" +dots="Y" ### Would you like to blacklist nouveau? (y/n) blacklist_nouveau="Y" @@ -37,4 +37,4 @@ install_sddm_theme="Y" ### " Please note that adding yourself to the 'input' group might be necessary for waybar keyboard-state functionality." input_group_choid="Y" ### OPTIONAL - Do you want to add Pokemon color scripts? (y/n): -pokemon_choice="N" +pokemon_choice="Y"