From 3a888f9be4b50f78d0544160698c3a44a484e3fd Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 07:13:51 +0800 Subject: [PATCH] Add pause(); distro specific also for setups --- scriptdata/environment-variables.sh | 6 ++ scriptdata/functions.sh | 3 + scriptdata/install-deps.sh | 14 ++-- scriptdata/install-files.sh | 1 + scriptdata/install-greeting.sh | 41 +++++++----- scriptdata/install-setups-arch.sh | 15 +++++ scriptdata/install-setups-fallback.sh | 15 +++++ scriptdata/install-setups-nix.sh | 15 +++++ scriptdata/install-setups.sh | 94 +++++++++++++++++++++++---- 9 files changed, 170 insertions(+), 34 deletions(-) create mode 100644 scriptdata/install-setups-arch.sh create mode 100644 scriptdata/install-setups-fallback.sh create mode 100644 scriptdata/install-setups-nix.sh diff --git a/scriptdata/environment-variables.sh b/scriptdata/environment-variables.sh index 0da81f112..d5eb8db68 100644 --- a/scriptdata/environment-variables.sh +++ b/scriptdata/environment-variables.sh @@ -7,6 +7,7 @@ XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} BACKUP_DIR=${BACKUP_DIR:-$HOME/backup} +# Note that all color styles contains a STY_RESET before it. STY_RED='\e[00m\e[31m' STY_GREEN='\e[00m\e[32m' STY_YELLOW='\e[00m\e[33m' @@ -21,5 +22,10 @@ STY_BG_BLUE='\e[30m\e[44m' STY_BG_PURPLE='\e[30m\e[45m' STY_BG_CYAN='\e[30m\e[46m' +STY_BOLD='\e[1m' +STY_FAINT='\e[2m' +STY_SLANT='\e[3m' STY_UNDERLINE='\e[4m' +STY_BLINK='\e[5m' +STY_INVERT='\e[7m' STY_RESET='\e[00m' diff --git a/scriptdata/functions.sh b/scriptdata/functions.sh index 19410b5eb..531df3ef3 100644 --- a/scriptdata/functions.sh +++ b/scriptdata/functions.sh @@ -63,6 +63,9 @@ function showfun(){ type -a $1 printf "${STY_RESET}" } +function pause(){ + if [ ! "$ask" == "false" ];then printf "${STY_FAINT}${STY_SLANT}";read -p "(Ctrl-C to abort, others to proceed)" p;printf "${STY_RESET}";fi +} function remove_bashcomments_emptylines(){ mkdir -p $(dirname $2) cat $1 | sed -e '/^[[:blank:]]*#/d;s/#.*//' -e '/^[[:space:]]*$/d' > $2 diff --git a/scriptdata/install-deps.sh b/scriptdata/install-deps.sh index a100d7885..5861ad199 100644 --- a/scriptdata/install-deps.sh +++ b/scriptdata/install-deps.sh @@ -41,6 +41,7 @@ if [[ "$INSTALL_VIA_NIX" == "true" ]]; then printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" + pause source ./scriptdata/install-deps-nix.sh elif [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros)$ ]]; then @@ -51,6 +52,7 @@ elif [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros)$ ]]; then printf "./scriptdata/install-deps-arch.sh will be used.\n" printf "\n" printf "${STY_RESET}" + pause source ./scriptdata/install-deps-arch.sh elif [[ -f "./scriptdata/install-deps-${OS_DISTRO_ID}.sh" ]]; then @@ -67,6 +69,7 @@ elif [[ -f "./scriptdata/install-deps-${OS_DISTRO_ID}.sh" ]]; then printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" + pause source ./scriptdata/install-deps-${OS_DISTRO_ID}.sh elif [[ "$OS_DISTRO_ID_LIKE" == "arch" ]]; then @@ -81,12 +84,13 @@ elif [[ "$OS_DISTRO_ID_LIKE" == "arch" ]]; then printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" + pause source ./scriptdata/install-deps-arch.sh else printf "${STY_RED}" - printf "===URGENT===\n" + printf "${STY_BOLD}===URGENT===${STY_RED}\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" printf "./scriptdata/install-deps-${OS_DISTRO_ID}.sh not found.\n" @@ -94,13 +98,7 @@ else printf "It may disrupt your system and will likely fail without your manual intervention.\n" printf "Proceed only at your own risk.\n" printf "${STY_RESET}" - printf "${STY_BG_RED}" - printf "To tell you the truth, it is completely not worky at this time. The prompt here is only for testing and WIP. PLEASE JUST QUIT IMMEDIATELY.${STY_RESET}\n" - read -p "Still continue? [y/N] ====> " p - case $p in - [yY]) sleep 0 ;; - *) exit 1 ;; - esac + pause source ./scriptdata/install-deps-fallback.sh fi diff --git a/scriptdata/install-files.sh b/scriptdata/install-files.sh index 7d39f2b4d..8a4ca9ba7 100644 --- a/scriptdata/install-files.sh +++ b/scriptdata/install-files.sh @@ -135,6 +135,7 @@ for i in ${warn_files_tests[@]}; do done ##################################################################################### +# TODO: output the logs below to a temp file and cat that file, also show the path of the file so users will be able to read it again. printf "\n" printf "\n" printf "\n" diff --git a/scriptdata/install-greeting.sh b/scriptdata/install-greeting.sh index 8fe80fda8..85a1633bb 100644 --- a/scriptdata/install-greeting.sh +++ b/scriptdata/install-greeting.sh @@ -3,27 +3,38 @@ ##################################################################################### -printf "${STY_BLUE}[$0]: Hi there! Before we start:\n" -printf '\n' -printf '[NEW] illogical-impulse is now powered by Quickshell. If you were using the old version with AGS and would like to keep it, do not run this script.\n' -printf ' The AGS version, although uses less memory, has much worse performance (it uses Gtk3). \n' -printf ' If you aren'\''t running on ewaste, the Quickshell version is recommended. \n' -printf ' If you would like the AGS version anyway, run the script in its branch instead: git checkout ii-ags && ./install.sh\n' -printf '\n' -printf 'This script does not handle system-level/hardware stuff like Nvidia drivers.\n' +printf "${STY_CYAN}[$0]: Hi there! Before we start:${STY_RESET}\n" printf "\n" +printf "${STY_PURPLE}${STY_BOLD}[NEW] illogical-impulse is now powered by Quickshell.${STY_PURPLE}\n" +printf '# If you were using the old version with AGS and would like to keep it, do not run this script.\n' +printf '# The AGS version, although uses less memory, has much worse performance (it uses Gtk3). \n' +printf '# If you aren'\''t running on ewaste, the Quickshell version is recommended. \n' +printf "# If you would like the AGS version anyway, run the script in its branch instead:\n ${STY_INVERT} git checkout ii-ags && ./install.sh ${STY_RESET}\n" +printf "\n" +pause +printf "${STY_CYAN}${STY_BOLD}Quick overview about what this script does:${STY_CYAN}\n" +printf " 1. Install dependencies.\n" +printf " 2. Setup permissions/services etc.\n" +printf " 3. Copying config files.${STY_RESET}\n" +pause +printf "${STY_CYAN}${STY_BOLD}Tips:${STY_CYAN}\n" +printf " a) It has been designed to be idempotent which means you can run it multiple times.\n" +printf " b) Use ${STY_INVERT} --help ${STY_CYAN} for more options.${STY_RESET}\n" +printf "${STY_YELLOW}${STY_BOLD}Note: ${STY_YELLOW}" +printf "It does not handle system-level/hardware stuff like Nvidia drivers.\n" printf "${STY_RESET}" +printf "\n" +pause case $ask in false) sleep 0 ;; *) - printf "${STY_RED}" - printf '\n' - printf 'Do you want to confirm every time before a command executes?\n' - printf ' y = Yes, ask me before executing each of them. (DEFAULT)\n' - printf ' n = No, I know everything this script will do, just execute them automatically.\n' - printf ' a = Abort.\n' - read -p "====> " p + printf "${STY_BLUE}" + printf "${STY_BOLD}Do you want to confirm every time before a command executes?${STY_BLUE}\n" + printf " y = Yes, ask me before executing each of them. (DEFAULT)\n" + printf " n = No, I know everything this script will do, just execute them automatically.\n" + printf " a = Abort.\n" + read -p "===> [Y/n/a]: " p case $p in n) ask=false ;; a) exit 1 ;; diff --git a/scriptdata/install-setups-arch.sh b/scriptdata/install-setups-arch.sh new file mode 100644 index 000000000..923ac2bc5 --- /dev/null +++ b/scriptdata/install-setups-arch.sh @@ -0,0 +1,15 @@ +# This script is meant to be sourced. +# It's not for directly running. + +##################################################################################### +# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. +showfun install-python-packages +v install-python-packages + +v sudo usermod -aG video,i2c,input "$(whoami)" +v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" +v systemctl --user enable ydotool --now +v sudo systemctl enable bluetooth --now +v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' +v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' +v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly diff --git a/scriptdata/install-setups-fallback.sh b/scriptdata/install-setups-fallback.sh new file mode 100644 index 000000000..923ac2bc5 --- /dev/null +++ b/scriptdata/install-setups-fallback.sh @@ -0,0 +1,15 @@ +# This script is meant to be sourced. +# It's not for directly running. + +##################################################################################### +# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. +showfun install-python-packages +v install-python-packages + +v sudo usermod -aG video,i2c,input "$(whoami)" +v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" +v systemctl --user enable ydotool --now +v sudo systemctl enable bluetooth --now +v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' +v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' +v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly diff --git a/scriptdata/install-setups-nix.sh b/scriptdata/install-setups-nix.sh new file mode 100644 index 000000000..923ac2bc5 --- /dev/null +++ b/scriptdata/install-setups-nix.sh @@ -0,0 +1,15 @@ +# This script is meant to be sourced. +# It's not for directly running. + +##################################################################################### +# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. +showfun install-python-packages +v install-python-packages + +v sudo usermod -aG video,i2c,input "$(whoami)" +v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" +v systemctl --user enable ydotool --now +v sudo systemctl enable bluetooth --now +v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' +v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' +v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly diff --git a/scriptdata/install-setups.sh b/scriptdata/install-setups.sh index 923ac2bc5..ebd3d97e3 100644 --- a/scriptdata/install-setups.sh +++ b/scriptdata/install-setups.sh @@ -1,15 +1,87 @@ # This script is meant to be sourced. # It's not for directly running. -##################################################################################### -# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. -showfun install-python-packages -v install-python-packages +#################### +# Detect distro +# Helpful link(s): +# http://stackoverflow.com/questions/29581754 +# https://github.com/which-distro/os-release +export OS_RELEASE_FILE=${OS_RELEASE_FILE:-/etc/os-release} +test -f ${OS_RELEASE_FILE} || \ + ( echo "${OS_RELEASE_FILE} does not exist. Aborting..." ; exit 1 ; ) +export OS_DISTRO_ID=$(awk -F'=' '/^ID=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null) +export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null) -v sudo usermod -aG video,i2c,input "$(whoami)" -v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" -v systemctl --user enable ydotool --now -v sudo systemctl enable bluetooth --now -v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' -v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' -v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly + + +if [[ "$INSTALL_VIA_NIX" == "true" ]]; then + + printf "${STY_YELLOW}" + printf "===WARNING===\n" + printf "Nix will be used to do setups.\n" + printf "The process is still WIP.\n" + printf "Proceed only at your own risk.\n" + printf "\n" + printf "${STY_RESET}" + pause + source ./scriptdata/install-setups-nix.sh + +elif [[ "$OS_DISTRO_ID" == "arch" ]]; then + + printf "${STY_GREEN}" + printf "===INFO===\n" + printf "Detected distro ID: ${OS_DISTRO_ID}\n" + printf "./scriptdata/install-setups-arch.sh will be used.\n" + printf "\n" + printf "${STY_RESET}" + pause + source ./scriptdata/install-setups-arch.sh + +elif [[ -f "./scriptdata/install-setups-${OS_DISTRO_ID}.sh" ]]; then + + printf "${STY_PURPLE}" + printf "===NOTICE===\n" + printf "Detected distro ID: ${OS_DISTRO_ID}\n" + printf "./scriptdata/install-setups-${OS_DISTRO_ID}.sh detected and will be used.\n" + printf "This file is provided by the community.\n" + printf "It is not officially supported by github:end-4/dots-hyprland .\n" + printf "${STY_BG_PURPLE}" + printf "If you find out any problems about it, PR is welcomed if you are able to address it. Or, create a discussion about it, but please do not submit issue, because the developers do not use this distro, therefore they cannot help.${STY_RESET}\n" + printf "${STY_PURPLE}" + printf "Proceed only at your own risk.\n" + printf "\n" + printf "${STY_RESET}" + pause + source ./scriptdata/install-setups-${OS_DISTRO_ID}.sh + +elif [[ "$OS_DISTRO_ID_LIKE" == "arch" ]]; then + + printf "${STY_YELLOW}" + printf "===WARNING===\n" + printf "Detected distro ID: ${OS_DISTRO_ID}\n" + printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" + printf "./scriptdata/install-setups-arch.sh will be used.\n" + printf "Ideally, it should also work for your distro.\n" + printf "Still, there is a chance that it not works as expected or even fails.\n" + printf "Proceed only at your own risk.\n" + printf "\n" + printf "${STY_RESET}" + pause + source ./scriptdata/install-setups-arch.sh + +else + + printf "${STY_RED}" + printf "===WARNING===\n" + printf "Detected distro ID: ${OS_DISTRO_ID}\n" + printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" + printf "./scriptdata/install-setups-${OS_DISTRO_ID}.sh not found.\n" + printf "./scriptdata/install-setups-fallback.sh will be used.\n" + printf "It might fail or disrupt your system.\n" + printf "Proceed only at your own risk.\n" + printf "\n" + printf "${STY_RESET}" + pause + source ./scriptdata/install-setups-fallback.sh + +fi