Rearrange sdata/subcmd; add --skip-backup

This commit is contained in:
clsty
2025-10-26 23:13:49 +08:00
parent 57a2e5aba4
commit 7f245e2896
13 changed files with 71 additions and 53 deletions
+52
View File
@@ -0,0 +1,52 @@
# This script is meant to be sourced.
# It's not for directly running.
# shellcheck shell=bash
#####################################################################################
printf "${STY_CYAN}[$0]: Hi there! Before we start:${STY_RST}\n"
printf "\n"
printf "${STY_PURPLE}${STY_BOLD}[NEW] illogical-impulse is now powered by Quickshell.${STY_RST}\n"
printf "${STY_PURPLE}"
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 following to switch to its branch first:\n ${STY_INVERT} git checkout ii-ags && ./install.sh ${STY_RST}\n"
printf "\n"
pause
printf "${STY_CYAN}${STY_BOLD}Quick overview about what this script does:${STY_RST}\n"
printf "${STY_CYAN}"
printf " 1. Install dependencies.\n"
printf " 2. Setup permissions/services etc.\n"
printf " 3. Copying config files.${STY_RST}\n"
pause
printf "${STY_CYAN}${STY_BOLD}Tips:${STY_RST}\n"
printf "${STY_CYAN}"
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_RST}${STY_CYAN} for more options.${STY_RST}\n"
printf "${STY_YELLOW}${STY_BOLD}Note: ${STY_RST}"
printf "${STY_YELLOW}"
printf "It does not handle system-level/hardware stuff like Nvidia drivers. Please do it by yourself.\n"
printf "${STY_RST}"
printf "\n"
pause
case $ask in
false) sleep 0 ;;
*)
printf "${STY_BLUE}"
printf "${STY_BOLD}Do you want to confirm every time before a command executes?${STY_RST}\n"
printf "${STY_BLUE}"
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 ;;
*) ask=true ;;
esac
printf "${STY_RST}"
;;
esac
+172
View File
@@ -0,0 +1,172 @@
# This script is meant to be sourced.
# It's not for directly running.
printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RST}"
function outdate_detect(){
# Shallow clone prevent latest_commit_timestamp() from working.
v git_auto_unshallow
local source_path="$1"
local target_path="$2"
local source_timestamp="$(latest_commit_timestamp $source_path 2>/dev/null)"
local target_timestamp="$(latest_commit_timestamp $target_path 2>/dev/null)"
local outdate_detect_mode="$(cat ${target_path}/outdate-detect-mode)"
# outdate-detect-mode possible modes:
# - WIP: Work in progress (should be taken as outdated)
# - FORCE_OUTDATED: forcely taken as outdated
# - FORCE_UPDATED: forcely taken as updated
# - AUTO: Let the script decide automatically
#
# outdate status possible values:
# - WIP,FORCE_OUTDATED,FORCE_UPDATED: Inherited directly from outdate-detect-mode
# - EMPTY_SOURCE: source path has empty timestamp, maybe not tracked by git (should be taken as outdated)
# - EMPTY_TARGET: target path has empty timestamp, maybe not tracked by git (should be taken as outdated)
# - OUTDATED: target path is older than source path.
# - UPDATED: target path is not older than source path.
# Does target path have an outdate-detect-mode file which content is special?
if [[ "${outdate_detect_mode}" =~ ^(WIP|FORCE_OUTDATED|FORCE_UPDATED)$ ]]; then
echo "${outdate_detect_mode}"
# Does source path has an empty timestamp?
elif [ -z "$source_timestamp" ]; then
echo "EMPTY_SOURCE"
# Does target path has an empty timestamp?
elif [ -z "$target_timestamp" ]; then
echo "EMPTY_TARGET"
# If target path is older than source path, it's outdated.
elif [[ "$target_timestamp" -lt "$source_timestamp" ]]; then
echo "OUTDATED"
else
echo "UPDATED"
fi
}
####################
# Detect architecture
# Helpful link(s):
# http://stackoverflow.com/questions/45125516
export MACHINE_ARCH=$(uname -m)
case $MACHINE_ARCH in
"x86_64") sleep 0;;
*)
printf "${STY_YELLOW}"
printf "===WARNING===\n"
printf "Detected machine architecture: ${MACHINE_ARCH}\n"
printf "This script only supports x86_64.\n"
printf "It is very likely to fail when installing dependencies on your machine.\n"
printf "\n"
printf "${STY_RST}"
pause
;;
esac
####################
# 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)
if [[ "$INSTALL_VIA_NIX" == "true" ]]; then
TARGET_ID=nix
printf "${STY_YELLOW}"
printf "===WARNING===\n"
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
printf "The process is still WIP.\n"
printf "Proceed only at your own risk.\n"
printf "\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-deps.sh
elif [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros)$ ]]; then
TARGET_ID=arch
printf "${STY_GREEN}"
printf "===INFO===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
printf "\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-deps.sh
elif [[ -f "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh" ]]; then
TARGET_ID=${OS_DISTRO_ID}
printf "${STY_PURPLE}"
printf "===NOTICE===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "./sdata/dist-${TARGET_ID}/install-deps.sh 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"
test -f "./sdata/dist-${TARGET_ID}/README.md" && \
printf "Read ${STY_INVERT} ./sdata/dist-${TARGET_ID}/README.md ${STY_RST}${STY_PURPLE} for more information.\n"
printf "${STY_BOLD}"
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_RST}\n"
printf "${STY_PURPLE}"
printf "Proceed only at your own risk.\n"
printf "\n"
printf "${STY_RST}"
pause
tmp_update_status="$(outdate_detect sdata/dist-arch sdata/dist-${TARGET_ID})"
if [[ "${tmp_update_status}" =~ ^(OUTDATED|EMPTY_TARGET|EMPTY_SOURCE|FORCE_OUTDATED|WIP)$ ]]; then
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
printf "${STY_RED}"
printf "The community provided ./sdata/dist-${TARGET_ID}/ is not updated (update status: ${tmp_update_status}),\n"
printf "which means it does not fully reflect the latest changes of ./sdata/dist-arch/ .\n"
printf "You are highly recommended to abort this script, until someone (maybe you?) has updated the ./sdata/dist-${TARGET_ID}/ to fully reflect the latest changes in ./sdata/dist-arch/ .\n"
printf "PR is welcomed. Please see discussion#2140 for details.\n"
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/discussions/2140${STY_RST}\n"
printf "${STY_RED}${STY_INVERT}If you are proceeding anyway, illogical-impulse will very likely not work as expected.${STY_RST}\n"
if [ "$ask" = "false" ]; then
echo "Urgent problem encountered, aborting...";exit 1
fi
printf "${STY_RED}Still proceed?${STY_RST}\n"
read -p "[y/N]: " p
case "$p" in
[yY])sleep 0;;
*)echo "Aborting...";exit 1;;
esac
fi
source ./sdata/dist-${TARGET_ID}/install-deps.sh
elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then
TARGET_ID=arch
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 "./sdata/dist-${TARGET_ID}/install-deps.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_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-deps.sh
else
TARGET_ID=fallback
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
printf "${STY_RED}"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n"
printf "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh not found.\n"
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
printf "1. It may disrupt your system and will likely fail without your manual intervention.\n"
printf "2. It's WIP and only contains small number of dependencies far from enough.\n"
printf "Proceed only at your own risk.\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-deps.sh
fi
+95
View File
@@ -0,0 +1,95 @@
# This script is meant to be sourced.
# It's not for directly running.
printf "${STY_CYAN}[$0]: 2. Setup for permissions/services etc\n${STY_RST}"
# shellcheck shell=bash
####################
# 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)
if [[ "$INSTALL_VIA_NIX" == "true" ]]; then
TARGET_ID=fallback
printf "${STY_YELLOW}"
printf "===WARNING===\n"
printf "./sdata/dist-${TARGET_ID}/install-setups.sh will be used.\n"
printf "The process is still WIP.\n"
printf "Proceed only at your own risk.\n"
printf "\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-setups.sh
elif [[ "$OS_DISTRO_ID" == "arch" ]]; then
TARGET_ID=arch
printf "${STY_GREEN}"
printf "===INFO===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "./sdata/dist-${TARGET_ID}/install-setups.sh will be used.\n"
printf "\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-setups.sh
elif [[ -f "./sdata/dist-${OS_DISTRO_ID}/install-setups.sh" ]]; then
TARGET_ID=${OS_DISTRO_ID}
printf "${STY_PURPLE}"
printf "===NOTICE===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "./sdata/dist-${TARGET_ID}/install-setups.sh 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_INVERT}"
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_RST}\n"
printf "${STY_PURPLE}"
printf "Proceed only at your own risk.\n"
printf "\n"
printf "${STY_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-setups.sh
elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then
TARGET_ID=arch
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 "./sdata/dist-${TARGET_ID}/install-setups.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_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-setups.sh
else
TARGET_ID=fallback
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 "./sdata/dist-${OS_DISTRO_ID}/install-setups.sh not found.\n"
printf "./sdata/dist-${TARGET_ID}/install-setups.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_RST}"
pause
source ./sdata/dist-${TARGET_ID}/install-setups.sh
fi
+255
View File
@@ -0,0 +1,255 @@
# This script is meant to be sourced.
# It's not for directly running.
printf "${STY_CYAN}[$0]: 3. Copying config files\n${STY_RST}"
# shellcheck shell=bash
# TODO: https://github.com/end-4/dots-hyprland/issues/2137
function warning_rsync(){
printf "${STY_YELLOW}"
printf "The commands using rsync will overwrite the destination when it exists already.\n"
printf "${STY_RST}"
}
function backup_clashing_targets(){
# For dirs/files under target_dir, only backup those which clashes with the ones under source_dir
# Deal with arguments
local source_dir="$1"
local target_dir="$2"
local backup_dir="$3"
# Find clash dirs/files, save as clash_list
local clash_list=()
local source_list=($(ls -A "$source_dir"))
local target_list=($(ls -A "$target_dir"))
declare -A target_map
for i in "${target_list[@]}"; do
target_map["$i"]=1
done
for i in "${source_list[@]}"; do
if [[ -n "${target_map[$i]}" ]]; then
clash_list+=("$i")
fi
done
# Construct args_includes for rsync
local args_includes=()
for i in "${clash_list[@]}"; do
if [[ -d "$target_dir/$i" ]]; then
args_includes+=(--include="/$i/")
args_includes+=(--include="/$i/**")
else
args_includes+=(--include="/$i")
fi
done
args_includes+=(--exclude='*')
x mkdir -p $backup_dir
x rsync -av --progress "${args_includes[@]}" "$target_dir/" "$backup_dir/"
}
function ask_backup_configs(){
showfun backup_clashing_targets
printf "${STY_RED}"
printf "Would you like to backup clashing dirs/files under \"$XDG_CONFIG_HOME\" and \"$XDG_DATA_HOME\" to \"$BACKUP_DIR\"?"
printf "${STY_RST}"
while true;do
echo " y = Yes, backup"
echo " n = No, skip to next"
local p; read -p "====> " p
case $p in
[yY]) echo -e "${STY_BLUE}OK, doing backup...${STY_RST}" ;local backup=true;break ;;
[nN]) echo -e "${STY_BLUE}Alright, skipping...${STY_RST}" ;local backup=false;break ;;
*) echo -e "${STY_RED}Please enter [y/n].${STY_RST}";;
esac
done
if $backup;then
backup_clashing_targets dots/.config $XDG_CONFIG_HOME "${BACKUP_DIR}/.config"
backup_clashing_targets dots/.local/share $XDG_DATA_HOME "${BACKUP_DIR}/.local/share"
printf "${STY_BLUE}Backup into \"${BACKUP_DIR}\" finished.${STY_RST}\n"
fi
}
function auto_backup_configs(){
# Backup when $BACKUP_DIR does not exist
if [[ ! -d "$BACKUP_DIR" ]]; then
backup_clashing_targets dots/.config $XDG_CONFIG_HOME "${BACKUP_DIR}/.config"
backup_clashing_targets dots/.local/share $XDG_DATA_HOME "${BACKUP_DIR}/.local/share"
printf "${STY_BLUE}Backup into \"${BACKUP_DIR}\" finished.${STY_RST}\n"
fi
}
#####################################################################################
# In case some dirs does not exists
v mkdir -p $XDG_BIN_HOME $XDG_CACHE_HOME $XDG_CONFIG_HOME/quickshell $XDG_DATA_HOME
if [[ ! "${SKIP_BACKUP}" == true ]]; then
case $ask in
false) auto_backup_configs ;;
*) ask_backup_configs ;;
esac
fi
# TODO: A better method for users to choose their customization,
# for example some users may prefer ZSH over FISH, and foot over kitty.
# But the dot files are using FISH and kitty as the default software, e.g. `.local/share/Konsole` has `Command=/bin/fish`.
# It may be possible that we provide options for users to make their decision.
# `--delete' for rsync to make sure that
# original dotfiles and new ones in the SAME DIRECTORY
# (eg. in ~/.config/hypr) won't be mixed together
# MISC (For dots/.config/* but not quickshell, not fish, not Hyprland)
case $SKIP_MISCCONF in
true) sleep 0;;
*)
for i in $(find dots/.config/ -mindepth 1 -maxdepth 1 ! -name 'quickshell' ! -name 'fish' ! -name 'hypr' -exec basename {} \;); do
# i="dots/.config/$i"
echo "[$0]: Found target: dots/.config/$i"
if [ -d "dots/.config/$i" ];then warning_rsync; v rsync -av --delete "dots/.config/$i/" "$XDG_CONFIG_HOME/$i/"
elif [ -f "dots/.config/$i" ];then warning_rsync; v rsync -av "dots/.config/$i" "$XDG_CONFIG_HOME/$i"
fi
done
;;
esac
case $SKIP_QUICKSHELL in
true) sleep 0;;
*)
warning_rsync; v rsync -av --delete dots/.config/quickshell/ii/ "$XDG_CONFIG_HOME"/quickshell/ii/
;;
esac
case $SKIP_FISH in
true) sleep 0;;
*)
warning_rsync; v rsync -av --delete dots/.config/fish/ "$XDG_CONFIG_HOME"/fish/
;;
esac
# For Hyprland
declare -a arg_excludes=()
arg_excludes+=(--exclude '/custom')
arg_excludes+=(--exclude '/hyprlock.conf')
arg_excludes+=(--exclude '/hypridle.conf')
arg_excludes+=(--exclude '/hyprland.conf')
case $SKIP_HYPRLAND in
true) sleep 0;;
*)
warning_rsync; v rsync -av --delete "${arg_excludes[@]}" dots/.config/hypr/ "$XDG_CONFIG_HOME"/hypr/
t="$XDG_CONFIG_HOME/hypr/hyprland.conf"
if [ -f $t ];then
echo -e "${STY_BLUE}[$0]: \"$t\" already exists.${STY_RST}"
v mv $t $t.old
v cp -f dots/.config/hypr/hyprland.conf $t
existed_hypr_conf_firstrun=y
else
echo -e "${STY_YELLOW}[$0]: \"$t\" does not exist yet.${STY_RST}"
v cp dots/.config/hypr/hyprland.conf $t
existed_hypr_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/hypridle.conf"
if [ -f $t ];then
echo -e "${STY_BLUE}[$0]: \"$t\" already exists.${STY_RST}"
v cp -f dots/.config/hypr/hypridle.conf $t.new
existed_hypridle_conf=y
else
echo -e "${STY_YELLOW}[$0]: \"$t\" does not exist yet.${STY_RST}"
v cp dots/.config/hypr/hypridle.conf $t
existed_hypridle_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/hyprlock.conf"
if [ -f $t ];then
echo -e "${STY_BLUE}[$0]: \"$t\" already exists.${STY_RST}"
v cp -f dots/.config/hypr/hyprlock.conf $t.new
existed_hyprlock_conf=y
else
echo -e "${STY_YELLOW}[$0]: \"$t\" does not exist yet.${STY_RST}"
v cp dots/.config/hypr/hyprlock.conf $t
existed_hyprlock_conf=n
fi
t="$XDG_CONFIG_HOME/hypr/custom"
if [ -d $t ];then
echo -e "${STY_BLUE}[$0]: \"$t\" already exists, will not do anything.${STY_RST}"
else
echo -e "${STY_YELLOW}[$0]: \"$t\" does not exist yet.${STY_RST}"
warning_rsync; v rsync -av --delete dots/.config/hypr/custom/ $t/
fi
;;
esac
declare -a arg_excludes=()
# some foldes (eg. .local/bin) should be processed separately to avoid `--delete' for rsync,
# since the files here come from different places, not only about one program.
# v rsync -av "dots/.local/bin/" "$XDG_BIN_HOME" # No longer needed since scripts are no longer in ~/.local/bin
warning_rsync; v rsync -av "dots/.local/share/icons/" "${XDG_DATA_HOME:-$HOME/.local/share}"/icons/
warning_rsync; v rsync -av "dots/.local/share/konsole/" "${XDG_DATA_HOME:-$HOME/.local/share}"/konsole/
# Prevent hyprland from not fully loaded
sleep 1
try hyprctl reload
existed_zsh_conf=n
grep -q 'source ${XDG_CONFIG_HOME:-~/.config}/zshrc.d/dots-hyprland.zsh' ~/.zshrc && existed_zsh_conf=y
warn_files=()
warn_files_tests=()
warn_files_tests+=(/usr/local/lib/{GUtils-1.0.typelib,Gvc-1.0.typelib,libgutils.so,libgvc.so})
warn_files_tests+=(/usr/local/share/fonts/TTF/Rubik{,-Italic}'[wght]'.ttf)
warn_files_tests+=(/usr/local/share/licenses/ttf-rubik)
warn_files_tests+=(/usr/local/share/fonts/TTF/Gabarito-{Black,Bold,ExtraBold,Medium,Regular,SemiBold}.ttf)
warn_files_tests+=(/usr/local/share/licenses/ttf-gabarito)
warn_files_tests+=(/usr/local/share/icons/OneUI{,-dark,-light})
warn_files_tests+=(/usr/local/share/icons/Bibata-Modern-Classic)
warn_files_tests+=(/usr/local/bin/{LaTeX,res})
for i in "${warn_files_tests[@]}"; do
echo $i
test -f $i && warn_files+=($i)
test -d $i && warn_files+=($i)
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"
printf "${STY_CYAN}[$0]: Finished${STY_RST}\n"
printf "\n"
printf "${STY_CYAN}When starting Hyprland from your display manager (login screen) ${STY_RED} DO NOT SELECT UWSM ${STY_RST}\n"
printf "\n"
printf "${STY_CYAN}If you are already running Hyprland,${STY_RST}\n"
printf "${STY_CYAN}Press ${STY_INVERT} Ctrl+Super+T ${STY_RST}${STY_CYAN} to select a wallpaper${STY_RST}\n"
printf "${STY_CYAN}Press ${STY_INVERT} Super+/ ${STY_RST}${STY_CYAN} for a list of keybinds${STY_RST}\n"
printf "\n"
printf "${STY_CYAN}For suggestions/hints after installation:${STY_RST}\n"
printf "${STY_CYAN}${STY_UNDERLINE} https://ii.clsty.link/en/ii-qs/01setup/#post-installation ${STY_RST}\n"
printf "\n"
case $existed_hypr_conf_firstrun in
y) printf "\n${STY_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. ${STY_RST}\n"
printf "${STY_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\".${STY_RST}\n"
;;esac
case $existed_hypr_conf in
y) printf "\n${STY_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprland.conf\" already existed before and we didn't overwrite it. ${STY_RST}\n"
printf "${STY_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hyprland.conf.new\" as a reference for a proper format.${STY_RST}\n"
;;esac
case $existed_hypridle_conf in
y) printf "\n${STY_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hypridle.conf\" already existed before and we didn't overwrite it. ${STY_RST}\n"
printf "${STY_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hypridle.conf.new\" as a reference for a proper format.${STY_RST}\n"
;;esac
case $existed_hyprlock_conf in
y) printf "\n${STY_YELLOW}[$0]: Warning: \"$XDG_CONFIG_HOME/hypr/hyprlock.conf\" already existed before and we didn't overwrite it. ${STY_RST}\n"
printf "${STY_YELLOW}Please use \"$XDG_CONFIG_HOME/hypr/hyprlock.conf.new\" as a reference for a proper format.${STY_RST}\n"
;;esac
if [[ -z "${ILLOGICAL_IMPULSE_VIRTUAL_ENV}" ]]; then
printf "\n${STY_RED}[$0]: \!! Important \!! : Please ensure environment variable ${STY_RST} \$ILLOGICAL_IMPULSE_VIRTUAL_ENV ${STY_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.${STY_RST}\n"
fi
if [[ ${#warn_files[@]} -gt 0 ]]; then
printf "\n${STY_RED}[$0]: \!! Important \!! : Please delete ${STY_RST} ${warn_files[*]} ${STY_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.${STY_RST}\n"
fi
+87
View File
@@ -0,0 +1,87 @@
# Handle args for subcmd: install
# shellcheck shell=bash
showhelp(){
echo -e "Syntax: $0 install [OPTIONS]...
Idempotent installation for dotfiles.
Options for install:
-h, --help Print this help message and exit
-f, --force (Dangerous) Force mode without any confirm
-c, --clean Clean the build cache first
--skip-allgreeting Skip the whole process greeting
--skip-alldeps Skip the whole process installing dependency
--skip-allsetups Skip the whole process setting up permissions/services etc
--skip-allfiles Skip the whole process copying configuration files
-s, --skip-sysupdate Skip system package upgrade e.g. \"sudo pacman -Syu\"
--skip-backup Skip backup conflicting files
--skip-quickshell Skip installing the config for Quickshell
--skip-hyprland Skip installing the config for Hyprland
--skip-fish Skip installing the config for Fish
--skip-plasmaintg Skip installing plasma-browser-integration
--skip-miscconf Skip copying the dirs and files to \".configs\" except for
Quickshell, Fish and Hyprland
--exp-files Use experimental script for the third step copying files
--fontset <set> (Unavailable yet) Use a set of pre-defined font and config
--via-nix (Unavailable yet) Use Nix to install dependencies
"
}
cleancache(){
rm -rf "${REPO_ROOT}/cache"
}
# `man getopt` to see more
para=$(getopt \
-o hfk:cs \
-l help,force,fontset:,clean,skip-allgreeting,skip-alldeps,skip-allsetups,skip-allfiles,skip-sysupdate,skip-backup,skip-quickshell,skip-fish,skip-hyprland,skip-plasmaintg,skip-miscconf,exp-files,via-nix \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
## getopt Phase 1
# ignore parameter's order, execute options below first
eval set -- "$para"
while true ; do
case "$1" in
-h|--help) showhelp;exit;;
-c|--clean) cleancache;shift;;
--) break ;;
*) shift ;;
esac
done
#####################################################################################
## getopt Phase 2
eval set -- "$para"
while true ; do
case "$1" in
## Already processed in phase 1, but not exited
-c|--clean) shift;;
## Ones without parameter
-f|--force) ask=false;shift;;
--skip-allgreeting) SKIP_ALLGREETING=true;shift;;
--skip-alldeps) SKIP_ALLDEPS=true;shift;;
--skip-allsetups) SKIP_ALLSETUPS=true;shift;;
--skip-allfiles) SKIP_ALLFILES=true;shift;;
-s|--skip-sysupdate) SKIP_SYSUPDATE=true;shift;;
--skip-backup) SKIP_BACKUP=true;shift;;
--skip-hyprland) SKIP_HYPRLAND=true;shift;;
--skip-fish) SKIP_FISH=true;shift;;
--skip-quickshell) SKIP_QUICKSHELL=true;shift;;
--skip-miscconf) SKIP_MISCCONF=true;shift;;
--skip-plasmaintg) SKIP_PLASMAINTG=true;shift;;
--exp-files) EXPERIMENTAL_FILES_SCRIPT=true;shift;;
--via-nix) INSTALL_VIA_NIX=true;shift;;
## Ones with parameter
--fontset)
case $2 in
"default"|"zh-CN"|"vi") fontset="$2";;
*) echo -e "Wrong argument for $1.";exit 1;;
esac;echo "The fontset is ${fontset}.";shift 2;;
## Ending
--) break ;;
*) echo -e "$0: Wrong parameters.";exit 1;;
esac
done