diff --git a/sdata/dist-arch/uninstall-deps.sh b/sdata/dist-arch/uninstall-deps.sh new file mode 100644 index 000000000..60dda0fd0 --- /dev/null +++ b/sdata/dist-arch/uninstall-deps.sh @@ -0,0 +1,6 @@ +# This script is meant to be sourced. +# It's not for directly running. + +for i in illogical-impulse-{quickshell-git,audio,backlight,basic,bibata-modern-classic-bin,fonts-themes,hyprland,kde,microtex-git,oneui4-icons-git,portal,python,screencapture,toolkit,widgets} plasma-browser-integration; do + v yay -Rns $i +done diff --git a/sdata/lib/environment-variables.sh b/sdata/lib/environment-variables.sh index 9b2a8ce91..affc1b61b 100644 --- a/sdata/lib/environment-variables.sh +++ b/sdata/lib/environment-variables.sh @@ -4,9 +4,6 @@ XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} -BACKUP_DIR=${BACKUP_DIR:-$HOME/ii-original-dots-backup} -INSTALLED_LISTFILE=${INSTALLED_LISTFILE:-$XDG_CONFIG_HOME/illogical-impulse/installed_listfile} - STY_RED='\e[31m' STY_GREEN='\e[32m' @@ -23,8 +20,11 @@ STY_BLINK='\e[5m' STY_INVERT='\e[7m' STY_RST='\e[00m' - # Used by register_temp_file() declare -a TEMP_FILES_TO_CLEANUP=() -FIRSTRUN_FILE="${XDG_CACHE_HOME}/.ii-qs-installed" +# Used by install script +BACKUP_DIR="${BACKUP_DIR:-$HOME/ii-original-dots-backup}" +DOTS_CORE_CONFDIR="${XDG_CONFIG_HOME}/illogical-impulse" +INSTALLED_LISTFILE="${DOTS_CORE_CONFDIR}/installed_listfile" +FIRSTRUN_FILE="${DOTS_CORE_CONFDIR}/installed_true" diff --git a/sdata/subcmd-exp-uninstall/0.run.sh b/sdata/subcmd-exp-uninstall/0.run.sh deleted file mode 100644 index 17aae32b4..000000000 --- a/sdata/subcmd-exp-uninstall/0.run.sh +++ /dev/null @@ -1,80 +0,0 @@ -# This script is meant to be sourced. -# It's not for directly running. - -# shellcheck shell=bash - -printf 'Hi there!\n' -printf 'This script 1. will uninstall [end-4/dots-hyprland > illogical-impulse] dotfiles\n' -printf ' 2. will try to revert *mostly everything* installed using "./setup install", so it'\''s pretty destructive\n' -printf ' 3. has not been tested, use at your own risk.\n' -printf ' 4. will show all commands that it runs.\n' -printf 'Ctrl+C to exit. Enter to continue.\n' -read -r -############################################################################################################################## - -# Undo Step 3: Removing copied config and local folders -printf "${STY_CYAN}Removing copied config and local folders...\n${STY_RST}" - -dirs=( -Kvantum/ -fish/ -fontconfig/ -foot/ -fuzzel/ -hypr/ -kde-material-you-colors/ -kitty/ -matugen/ -mpv/ -qt5ct/ -qt6ct/ -quickshell/ -wlogout/ -xdg-desktop-portal/ -zshrc.d/ -chrome-flags.conf -code-flags.conf -darklyrc -dolphinrc -kdeglobals -konsolerc -starship.toml -thorium-flags.conf -) - -for i in "${dirs[@]}" - do v rm -rf "$XDG_CONFIG_HOME/$i" -done - -for i in "glib-2.0/schemas/com.github.GradienceTeam.Gradience.Devel.gschema.xml" "gradience" - do v rm -rf "$XDG_DATA_HOME/$i" -done -v rm -rf "$XDG_CACHE_HOME/quickshell" -v sudo rm -rf "$XDG_STATE_HOME/quickshell" - -############################################################################################################################## - -# Undo Step 2: Uninstall AGS - Disabled for now, check issues -# echo 'Uninstalling AGS...' -# sudo meson uninstall -C ~/ags/build -# rm -rf ~/ags - -############################################################################################################################## - -# Undo Step 1: Remove added user from video, i2c, and input groups and remove yay packages -printf "${STY_CYAN}Removing user from video, i2c, and input groups and removing packages...\n${STY_RST}" -user=$(whoami) -v sudo gpasswd -d "$user" video -v sudo gpasswd -d "$user" i2c -v sudo gpasswd -d "$user" input -v sudo rm /etc/modules-load.d/i2c-dev.conf - -############################################################################################################################## -read -p "Do you want to uninstall the illogical-impulse-* meta packages (Arch Linux only)? -Ctrl+C to exit, or press Enter to proceed" p - -# Removing installed yay packages and dependencies -v yay -Rns illogical-impulse-{audio,backlight,basic,bibata-modern-classic-bin,fonts-themes,hyprland,kde,microtex-git,oneui4-icons-git,portal,python,screencapture,toolkit,widgets} plasma-browser-integration - -printf "${STY_CYAN}Uninstall Complete.\n${STY_RST}" -printf "${STY_CYAN}Hint: If you had agreed to backup when you ran \"./setup install\", you should be able to find it under \"$BACKUP_DIR\".\n${STY_RST}" diff --git a/sdata/subcmd-install/3.files-legacy.sh b/sdata/subcmd-install/3.files-legacy.sh index 6c2d7ddf4..267744b5f 100644 --- a/sdata/subcmd-install/3.files-legacy.sh +++ b/sdata/subcmd-install/3.files-legacy.sh @@ -5,29 +5,29 @@ function gen_firstrun(){ x mkdir -p "$(dirname ${FIRSTRUN_FILE})" - x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" x touch "${FIRSTRUN_FILE}" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" realpath -se "${FIRSTRUN_FILE}" >> "${INSTALLED_LISTFILE}" } cp_file(){ # NOTE: This function is only for using in other functions x mkdir -p "$(dirname $2)" - x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" x cp -f "$1" "$2" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" realpath -se "$2" >> "${INSTALLED_LISTFILE}" } rsync_dir(){ # NOTE: This function is only for using in other functions x mkdir -p "$2" - x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" local dest="$(realpath -se $2)" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" rsync -a --out-format='%i %n' "$1"/ "$2"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" } rsync_dir__sync(){ # NOTE: This function is only for using in other functions x mkdir -p "$2" - x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" local dest="$(realpath -se $2)" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" rsync -a --delete --out-format='%i %n' "$1"/ "$2"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" } function install_file(){ @@ -87,6 +87,26 @@ function install_dir__skip_existed(){ v rsync_dir $s $t fi } +function install_google_sans_flex(){ + local font_name="Google Sans Flex" + local src_name="google-sans-flex" + local src_url="https://github.com/end-4/google-sans-flex" + local src_dir="$REPO_ROOT/cache/$src_name" + local target_dir="${XDG_DATA_HOME}/fonts/illogical-impulse-$src_name" + if fc-list | grep -qi "$font_name"; then return; fi + x mkdir -p $src_dir + x cd $src_dir + try git init -b main + try git remote add origin $src_url + x git pull origin main + x git submodule update --init --recursive + warning_overwrite + rsync_dir "$src_dir" "$target_dir" + x fc-cache -fv + x cd $REPO_ROOT + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" + realpath -se "$2" >> "${INSTALLED_LISTFILE}" +} ##################################################################################### # In case some dirs does not exists @@ -120,7 +140,7 @@ case "${SKIP_MISCCONF}" in elif [ -f "dots/.config/$i" ];then install_file "dots/.config/$i" "$XDG_CONFIG_HOME/$i" fi done - install_dir "dots/.local/share/konsole" "${XDG_DATA_HOME:-$HOME/.local/share}"/konsole + install_dir "dots/.local/share/konsole" "${XDG_DATA_HOME}"/konsole ;; esac @@ -172,6 +192,8 @@ case "${SKIP_HYPRLAND}" in esac install_file "dots/.local/share/icons/illogical-impulse.svg" "${XDG_DATA_HOME}"/icons/illogical-impulse.svg +showfun install_google_sans_flex +v install_google_sans_flex v dedup_and_sort_listfile "${INSTALLED_LISTFILE}" "${INSTALLED_LISTFILE}" v gen_firstrun diff --git a/sdata/subcmd-uninstall/0.run.sh b/sdata/subcmd-uninstall/0.run.sh new file mode 100644 index 000000000..380da51a7 --- /dev/null +++ b/sdata/subcmd-uninstall/0.run.sh @@ -0,0 +1,135 @@ +# This script is meant to be sourced. +# It's not for directly running. + +# shellcheck shell=bash + +printf "${STY_RED}" +printf "===CAUTION===\n" +printf "This script will try to revert changes made by \"./setup install\".\n" +printf "However:\n" +printf "1. It is far from enough to precisely revert all changes.\n" +printf "2. It has not been fully tested, use at your own risk.\n" +printf "${STY_RST}" +pause +############################################################################################################################## + +# Undo Step 3 +printf "${STY_CYAN}Undo install step 3...\n${STY_RST}" + +function view_listfile(){ + local listfile="$1" + if command -v less >/dev/null; then + less "$listfile" + else + cat "$listfile" + fi +} + +function edit_listfile(){ + local listfile="$1" + for ed in "$EDITOR" nano vim nvim vi; do + if command -v $ed >/dev/null; then + x $ed "$listfile" + return + fi + done + printf "Failed to find an available editor, please manually edit \"$listfile\".\n" +} + +function delete_targets(){ + local listfile="$1" + local targets=() + readarray -t targets < "$listfile" + for path in "${targets[@]}"; do + if [[ ! -e "$path" ]]; then + printf "${STY_YELLOW}Target \"$path\" inexists, skipping...${STY_RST}\n" + continue + elif [[ "$path" == "$HOME"* ]]; then + x rm -- "$path" + else + while true; do + printf "WARNING: Target \"$path\" is not under \$HOME. Still delete it?\ny=Yes, delete it;\nn=No, skip this one\n" + read -n1 -p "> " ans < /dev/tty + echo + case "$ans" in + y|Y) + x rm -- "$path" + break 1 + ;; + n|N) + break 1 + ;; + *) + ;; + esac + done + fi + done +} + +function deletion_prompt(){ + local listfile="$1" + while true; do + printf "Every target which path as a line inside the list \"$listfile\" will be deleted permanently.\n" + printf "Please choose:\nv=View the list\ne=Edit the list\nq=Quit\ny=Perform deletion now\n" + read -n1 -p "> " choice < /dev/tty + echo + case "$choice" in + q|Q) + printf "Quiting...\n" + break + ;; + y|Y) + delete_targets "$listfile" + break + ;; + v|V) + view_listfile "$listfile" + ;; + e|E) + edit_listfile "$listfile" + ;; + *) + ;; + esac + done +} + +deletion_prompt "${INSTALLED_LISTFILE}" + +empty_dir_listfile=$(mktemp) +scan_paths=(${XDG_CONFIG_HOME} "${XDG_DATA_HOME}"/konsole) +for dir in "${scan_paths[@]}"; do + find "$dir" -type d -empty -print >> $empty_dir_listfile +done +x dedup_and_sort_listfile "$empty_dir_listfile" "$empty_dir_listfile" +deletion_prompt "$empty_dir_listfile" + +############################################################################################################################## + +printf "${STY_CYAN}Undo install step 2...\n${STY_RST}" +user=$(whoami) +warn_undo_break_system(){ + printf "${STY_YELLOW}WARNING: The command below could break your system functionality. If you are unsure about it, just skip the command.${STY_RST}\n" +} +warn_undo_break_system +v sudo gpasswd -d "$user" video +warn_undo_break_system +v sudo gpasswd -d "$user" i2c +warn_undo_break_system +v sudo gpasswd -d "$user" input +warn_undo_break_system +v sudo rm /etc/modules-load.d/i2c-dev.conf + +############################################################################################################################## + +printf "${STY_CYAN}Undo install step 1...\n${STY_RST}" + +if test -f sdata/dist-$OS_GROUP_ID/uninstall-deps.sh; then + source sdata/dist-$OS_GROUP_ID/uninstall-deps.sh +else + printf "${STY_YELLOW}Automatic depedencies uninstallation is not yet avaible for your distro. Skipping...${STY_RST}\n" +fi + +printf "${STY_CYAN}Uninstall script finished.\n${STY_RST}" +printf "${STY_CYAN}Hint: If you had agreed to backup when you ran \"./setup install\", you should be able to find it under \"$BACKUP_DIR\".\n${STY_RST}" diff --git a/sdata/subcmd-exp-uninstall/options.sh b/sdata/subcmd-uninstall/options.sh similarity index 82% rename from sdata/subcmd-exp-uninstall/options.sh rename to sdata/subcmd-uninstall/options.sh index df2230f8b..c2bd17482 100644 --- a/sdata/subcmd-exp-uninstall/options.sh +++ b/sdata/subcmd-uninstall/options.sh @@ -1,10 +1,10 @@ -# Handle args for subcmd: exp-uninstall +# Handle args for subcmd: uninstall # shellcheck shell=bash showhelp(){ -echo -e "Syntax: $0 exp-uninstall [OPTIONS]... +echo -e "Syntax: $0 uninstall [OPTIONS]... -Experimental unintallation. +Unintall dots. Options: -h, --help Show this help message diff --git a/setup b/setup index 9715ea721..938c50979 100755 --- a/setup +++ b/setup @@ -15,7 +15,7 @@ showhelp_global(){ printf "${STY_CYAN}NOTE: The old \"./install.sh\" is now \"./setup install\" The old \"./update.sh\" is now \"./setup exp-update\" - The old \"./uninstall.sh\" is now \"./setup exp-uninstall\"${STY_RST} + The old \"./uninstall.sh\" is now \"./setup uninstall\"${STY_RST} [$0]: Handle setup for illogical-impulse. @@ -30,7 +30,7 @@ Subcommands: install-files Run the install step \"3. Copying config files\" resetfirstrun Reset firstrun state. - exp-uninstall (Experimental) Uninstall illogical-impulse. + uninstall Uninstall illogical-impulse. exp-update (Experimental) Update illogical-impulse without fully reinstall. exp-update-old (Experimental) exp-update but use behaves like old version. exp-merge (Experimental) Merge upstream changes with local configs using git rebase.