Use variable to store color for script output

This commit is contained in:
clsty
2025-10-01 21:40:06 +08:00
parent 87c031b825
commit 9f711c20e0
9 changed files with 87 additions and 73 deletions
+27 -27
View File
@@ -13,14 +13,14 @@ function backup_configs() {
}
function ask_backup_configs() {
printf "\e[31m"
printf "${COLOR_RED}"
printf "Would you like to create a backup for \"$XDG_CONFIG_HOME\" and \"$HOME/.local/\" folders?\n[y/N]: "
read -p " " backup_confirm
case $backup_confirm in
[yY][eE][sS]|[yY]) backup_configs ;;
*) echo "Skipping backup..." ;;
esac
printf "\e[00m"
printf "${COLOR_RESET}"
}
#####################################################################################
@@ -65,40 +65,40 @@ case $SKIP_HYPRLAND in
v rsync -av --delete --exclude '/custom' --exclude '/hyprlock.conf' --exclude '/hypridle.conf' --exclude '/hyprland.conf' .config/hypr/ "$XDG_CONFIG_HOME"/hypr/
t="$XDG_CONFIG_HOME/hypr/hyprland.conf"
if [ -f $t ];then
echo -e "\e[34m[$0]: \"$t\" already exists.\e[0m"
echo -e "${COLOR_BLUE}[$0]: \"$t\" already exists.${COLOR_RESET}"
v mv $t $t.old
v cp -f .config/hypr/hyprland.conf $t
existed_hypr_conf_firstrun=y
else
echo -e "\e[33m[$0]: \"$t\" does not exist yet.\e[0m"
echo -e "${COLOR_YELLOW}[$0]: \"$t\" does not exist yet.${COLOR_RESET}"
v cp .config/hypr/hyprland.conf $t
existed_hypr_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/hypridle.conf"
if [ -f $t ];then
echo -e "\e[34m[$0]: \"$t\" already exists.\e[0m"
echo -e "${COLOR_BLUE}[$0]: \"$t\" already exists.${COLOR_RESET}"
v cp -f .config/hypr/hypridle.conf $t.new
existed_hypridle_conf=y
else
echo -e "\e[33m[$0]: \"$t\" does not exist yet.\e[0m"
echo -e "${COLOR_YELLOW}[$0]: \"$t\" does not exist yet.${COLOR_RESET}"
v cp .config/hypr/hypridle.conf $t
existed_hypridle_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/hyprlock.conf"
if [ -f $t ];then
echo -e "\e[34m[$0]: \"$t\" already exists.\e[0m"
echo -e "${COLOR_BLUE}[$0]: \"$t\" already exists.${COLOR_RESET}"
v cp -f .config/hypr/hyprlock.conf $t.new
existed_hyprlock_conf=y
else
echo -e "\e[33m[$0]: \"$t\" does not exist yet.\e[0m"
echo -e "${COLOR_YELLOW}[$0]: \"$t\" does not exist yet.${COLOR_RESET}"
v cp .config/hypr/hyprlock.conf $t
existed_hyprlock_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/custom"
if [ -d $t ];then
echo -e "\e[34m[$0]: \"$t\" already exists, will not do anything.\e[0m"
echo -e "${COLOR_BLUE}[$0]: \"$t\" already exists, will not do anything.${COLOR_RESET}"
else
echo -e "\e[33m[$0]: \"$t\" does not exist yet.\e[0m"
echo -e "${COLOR_YELLOW}[$0]: \"$t\" does not exist yet.${COLOR_RESET}"
v rsync -av --delete .config/hypr/custom/ $t/
fi
;;
@@ -138,39 +138,39 @@ done
printf "\n"
printf "\n"
printf "\n"
printf "\e[36m[$0]: Finished\e[0m\n"
printf "${COLOR_CYAN}[$0]: Finished${COLOR_RESET}\n"
printf "\n"
printf "\e[36mWhen starting Hyprland from your display manager (login screen) \e[30m\e[46m DO NOT SELECT UWSM \e[0m\e[36m\e[0m\n"
printf "${COLOR_CYAN}When starting Hyprland from your display manager (login screen) ${COLOR_RED} DO NOT SELECT UWSM ${COLOR_RESET}\n"
printf "\n"
printf "\e[36mIf you are already running Hyprland,\e[0m\n"
printf "\e[36mPress \e[30m\e[46m Ctrl+Super+T \e[0m\e[36m to select a wallpaper\e[0m\n"
printf "\e[36mPress \e[30m\e[46m Super+/ \e[0m\e[36m for a list of keybinds\e[0m\n"
printf "${COLOR_CYAN}If you are already running Hyprland,${COLOR_RESET}\n"
printf "${COLOR_CYAN}Press ${BG_COLOR_CYAN} Ctrl+Super+T ${BG_COLOR_CYAN} to select a wallpaper${COLOR_RESET}\n"
printf "${COLOR_CYAN}Press ${BG_COLOR_CYAN} Super+/ ${COLOR_CYAN} for a list of keybinds${COLOR_RESET}\n"
printf "\n"
printf "\e[36mFor suggestions/hints after installation:\e[0m\n"
printf "\e[36m\e[4m https://end-4.github.io/dots-hyprland-wiki/en/ii-qs/01setup/#post-installation \e[0m\n"
printf "${COLOR_CYAN}For suggestions/hints after installation:${COLOR_RESET}\n"
printf "${COLOR_CYAN}${STYLE_UNDERLINE} https://end-4.github.io/dots-hyprland-wiki/en/ii-qs/01setup/#post-installation ${COLOR_RESET}\n"
printf "\n"
case $existed_hypr_conf_firstrun in
y) printf "\n\e[33m[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprland.conf\" already existed before. As it seems it is your first run, we replaced it with a new one. \e[0m\n"
printf "\e[33mAs it seems it is your first run, we replaced it with a new one. The old one has been renamed to \"$XDG_CONFIG_HOME/hypr/hyprland.conf.old\".\e[0m\n"
y) printf "\n${COLOR_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprland.conf\" already existed before. As it seems it is your first run, we replaced it with a new one. ${COLOR_RESET}\n"
printf "${COLOR_YELLOW}As it seems it is your first run, we replaced it with a new one. The old one has been renamed to \"$XDG_CONFIG_HOME/hypr/hyprland.conf.old\".${COLOR_RESET}\n"
;;esac
case $existed_hypr_conf in
y) printf "\n\e[33m[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprland.conf\" already existed before and we didn't overwrite it. \e[0m\n"
printf "\e[33mPlease use \"$XDG_CONFIG_HOME/hypr/hyprland.conf.new\" as a reference for a proper format.\e[0m\n"
y) printf "\n${COLOR_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprland.conf\" already existed before and we didn't overwrite it. ${COLOR_RESET}\n"
printf "${COLOR_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hyprland.conf.new\" as a reference for a proper format.${COLOR_RESET}\n"
;;esac
case $existed_hypridle_conf in
y) printf "\n\e[33m[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hypridle.conf\" already existed before and we didn't overwrite it. \e[0m\n"
printf "\e[33mPlease use \"$XDG_CONFIG_HOME/hypr/hypridle.conf.new\" as a reference for a proper format.\e[0m\n"
y) printf "\n${COLOR_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hypridle.conf\" already existed before and we didn't overwrite it. ${COLOR_RESET}\n"
printf "${COLOR_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hypridle.conf.new\" as a reference for a proper format.${COLOR_RESET}\n"
;;esac
case $existed_hyprlock_conf in
y) printf "\n\e[33m[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprlock.conf\" already existed before and we didn't overwrite it. \e[0m\n"
printf "\e[33mPlease use \"$XDG_CONFIG_HOME/hypr/hyprlock.conf.new\" as a reference for a proper format.\e[0m\n"
y) printf "\n${COLOR_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprlock.conf\" already existed before and we didn't overwrite it. ${COLOR_RESET}\n"
printf "${COLOR_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hyprlock.conf.new\" as a reference for a proper format.${COLOR_RESET}\n"
;;esac
if [[ -z "${ILLOGICAL_IMPULSE_VIRTUAL_ENV}" ]]; then
printf "\n\e[31m[$0]: \!! Important \!! : Please ensure environment variable \e[0m \$ILLOGICAL_IMPULSE_VIRTUAL_ENV \e[31m is set to proper value (by default \"~/.local/state/quickshell/.venv\"), or Quickshell config will not work. We have already provided this configuration in ~/.config/hypr/hyprland/env.conf, but you need to ensure it is included in hyprland.conf, and also a restart is needed for applying it.\e[0m\n"
printf "\n${COLOR_RED}[$0]: \!! Important \!! : Please ensure environment variable ${COLOR_RESET} \$ILLOGICAL_IMPULSE_VIRTUAL_ENV ${COLOR_RED} is set to proper value (by default \"~/.local/state/quickshell/.venv\"), or Quickshell config will not work. We have already provided this configuration in ~/.config/hypr/hyprland/env.conf, but you need to ensure it is included in hyprland.conf, and also a restart is needed for applying it.${COLOR_RESET}\n"
fi
if [[ ! -z "${warn_files[@]}" ]]; then
printf "\n\e[31m[$0]: \!! Important \!! : Please delete \e[0m ${warn_files[*]} \e[31m manually as soon as possible, since we\'re now using AUR package or local PKGBUILD to install them for Arch(based) Linux distros, and they'll take precedence over our installation, or at least take up more space.\e[0m\n"
printf "\n${COLOR_RED}[$0]: \!! Important \!! : Please delete ${COLOR_RESET} ${warn_files[*]} ${COLOR_RED} manually as soon as possible, since we\'re now using AUR package or local PKGBUILD to install them for Arch(based) Linux distros, and they'll take precedence over our installation, or at least take up more space.${COLOR_RESET}\n"
fi