✨ script(apply, update-repo): organize scripts into different files
This commit is contained in:
@@ -1,74 +1,31 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
source ./utils.sh
|
||||
|
||||
set -e
|
||||
trap "printf \"\nOk! Quitting beacuse you entered an exit signal.\n\"; exit 1" SIGINT
|
||||
|
||||
printf "\n"
|
||||
echo "######################################"
|
||||
echo "## Retrozinndev's Hyprland Dotfiles ##"
|
||||
echo "######################################"
|
||||
printf "\n"
|
||||
|
||||
CONFIG_DIR="$HOME/.config"
|
||||
DOTFILES_DIRS=("hypr" "ags" "kitty" "anyrun" "wal" "fastfetch")
|
||||
DOTFILES_BACKUP_DIR="$HOME/hyprland-dotfiles-bkp"
|
||||
|
||||
echo "Welcome to my dotfiles installation script!"
|
||||
|
||||
# Warn user of possible problems that can happen
|
||||
echo "WARN! Running this script may cause problems with your system. When continuing, you're confirming that any problem that may happen with your system is of **your** responsability."
|
||||
trap "printf \"\nOk, quitting beacuse you entered an exit signal. (SIGINT).\n\"; exit 1" SIGINT
|
||||
trap "printf \"\nOh noo!! Some application just told the script to end!\"; exit 2" SIGTERM
|
||||
|
||||
function Backup_previous_dotfiles {
|
||||
echo -n "Would you like to make a backup of the current dotfiles? [y/n] "
|
||||
read make_backup_answer
|
||||
read answer
|
||||
printf "\n"
|
||||
if [[ $make_backup_answer =~ "y" ]]
|
||||
then
|
||||
echo "[info] Creating backup dir in $DOTFILES_BACKUP_DIR"
|
||||
|
||||
if [[ -d $DOTFILES_BACKUP_DIR ]]
|
||||
then
|
||||
echo "Looks like the backup directory already exists!"
|
||||
echo -n "Would you like to override it with the current configuration? (Will be moved to trash) [y/n] "
|
||||
read override_backup
|
||||
|
||||
if [[ $override_backup = "y" ]] || [[ $override_backup = "yes" ]]
|
||||
then
|
||||
echo "Ok! The backup folder will be ovewritten with the current user configuration."
|
||||
trash-put $DOTFILES_BACKUP_DIR
|
||||
fi
|
||||
else
|
||||
mkdir $DOTFILES_BACKUP_DIR
|
||||
fi
|
||||
|
||||
# Make backup of existing configurations
|
||||
for dir in ${DOTFILES_DIRS[@]}; do
|
||||
if [[ -d "$CONFIG_DIR/$dir" ]]
|
||||
then
|
||||
echo "-> Making backup of $dir"
|
||||
cp -r "$CONFIG_DIR/$dir" $DOTFILES_BACKUP_DIR
|
||||
else
|
||||
echo "[info] $dir backup was skipped, because it wasn't found."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished backup!!"
|
||||
|
||||
if [[ $answer =~ "y" ]]
|
||||
then
|
||||
. ./backup-dots.sh
|
||||
else
|
||||
echo "Fine! Current settings will be overwritten, skipping backup :D"
|
||||
|
||||
echo "Ok! Directories will be overwritten, skipping backup :3"
|
||||
fi
|
||||
}
|
||||
|
||||
function Apply_wallpapers {
|
||||
|
||||
echo -n "Would you also like to apply the wallpapers folder? :3 [y/n] "
|
||||
read input_wallpaper
|
||||
read answer
|
||||
printf "\n"
|
||||
|
||||
if [[ $input_wallpaper =~ "y" ]]
|
||||
then
|
||||
echo "Thanks for installing these wallpapers! Oh, remember that I am not the author of them!"
|
||||
if [[ $answer =~ "y" ]]; then
|
||||
echo "Thanks for choosing! Please remember that I am not the author of the wallpapers!"
|
||||
echo "You can see sources in the repo: https://github.com/retrozinndev/Hyprland-Dots/WALLPAPERS.md"
|
||||
|
||||
echo "-> Copying wallpapers to ~/wallpapers"
|
||||
@@ -80,48 +37,49 @@ function Apply_wallpapers {
|
||||
fi
|
||||
}
|
||||
|
||||
function Apply_dotfiles {
|
||||
|
||||
printf "\n"
|
||||
for dir in ${config_dirs[@]}; do
|
||||
if ! [[ -d ./$dir ]]; then
|
||||
Send_log error "$dir is in fault, or you didn't run this script in its directory!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Start of actual script
|
||||
Print_header
|
||||
|
||||
echo "Welcome to my dotfiles installation script!"
|
||||
|
||||
# Warn user of possible problems that can happen
|
||||
echo "!!!WARNING!!! Running this may cause issues to your system if you don't know what you're doing! When continuing, you agree that any problem that may happen with the system is of your responsability!"
|
||||
|
||||
echo -n "Do you want to run the retrozinndev/Hyprland-Dots installer? [y/n] "
|
||||
read input
|
||||
|
||||
if [[ $input =~ "y" ]]; then
|
||||
printf "\n"
|
||||
Backup_previous_dotfiles
|
||||
printf "\n"
|
||||
|
||||
printf "Starting dotfiles installation...\n"
|
||||
Send_log "Starting installation\n"
|
||||
|
||||
for dir in ${DOTFILES_DIRS[@]}; do
|
||||
echo "-> Installing $dir in $CONFIG_DIR/$dir"
|
||||
mkdir -p $CONFIG_DIR/$dir
|
||||
cp -rf ./$dir/* $CONFIG_DIR/$dir
|
||||
for dir in ${config_dirs[@]}; do
|
||||
dest=$XDG_CONFIG_HOME/$dir
|
||||
|
||||
echo "-> Installing $dir in $dest"
|
||||
mkdir -p $dest
|
||||
cp -rf ./$dir/* $dest
|
||||
done
|
||||
|
||||
# Ask if user wants to apply repo's wallpapers dir
|
||||
Apply_wallpapers
|
||||
|
||||
echo "Ah yes! Looks like it's ready to use, yay :3"
|
||||
echo "If you find any issue, please report at: https://github.com/retrozinndev/Hyprland-Dots/issues"
|
||||
echo "Thanks for using my dotfiles! I'm really happy about that :3"
|
||||
echo -e "If you find any issue, please report it in:
|
||||
https://github.com/retrozinndev/Hyprland-Dots/issues"
|
||||
echo "Thanks for using my Hyprland-Dots! I'm really happy about that :3"
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
for dir in ${DOTFILES_DIRS[@]}; do
|
||||
if ! [[ -d ./$dir ]]; then
|
||||
echo "[error] Looks like $dir configuration is in fault, or you didn't run this script in its directory!"
|
||||
echo "[tip] If directory doesn't exist, try cloning the dotfiles again."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo -n "Do you want to install the dotfiles? [y/n] "
|
||||
read input
|
||||
|
||||
if [[ $input =~ "y" ]]
|
||||
then
|
||||
Apply_dotfiles
|
||||
else
|
||||
printf "Ok, doing as you said! Bye bye!\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "\n"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user