feat(apply.sh): super cool and optimized script hehe

This commit is contained in:
João Dias
2024-09-04 22:34:34 -03:00
parent a5bde6881a
commit 0a80ff2af1
+27 -43
View File
@@ -10,7 +10,7 @@ echo "######################################"
printf "\n" printf "\n"
CONFIG_DIR="$HOME/.config" CONFIG_DIR="$HOME/.config"
DOTFILES_DIRS=("hypr" "waybar" "swaync" "wlogout" "wofi") DOTFILES_DIRS=("hypr" "waybar" "swaync" "wlogout" "anyrun" "wal")
DOTFILES_BACKUP_DIR="$HOME/hyprland-dotfiles-bkp" DOTFILES_BACKUP_DIR="$HOME/hyprland-dotfiles-bkp"
TRASH_DIR="$HOME/.local/share/Trash/files" TRASH_DIR="$HOME/.local/share/Trash/files"
@@ -20,16 +20,18 @@ echo "Welcome to my dotfiles installation script!"
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." 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."
function Backup_previous_dotfiles { function Backup_previous_dotfiles {
echo -n "Would you like to make a backup of the current dotfiles? [y/n] "
echo "Making backup before installing dotfiles..." read make_backup_answer
printf "\n"
if [[ $make_backup_answer =~ "y" ]]
then
echo "[info] Creating backup dir in $DOTFILES_BACKUP_DIR" echo "[info] Creating backup dir in $DOTFILES_BACKUP_DIR"
if [[ -d $DOTFILES_BACKUP_DIR ]] if [[ -d $DOTFILES_BACKUP_DIR ]]
then then
echo "Looks like the backup directory already exists!" 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 dir) [y/n] " echo -n "Would you like to override it with the current configuration? (Will be deleted forever) [y/n] "
read override_backup read override_backup
printf "\n"
if [[ $override_backup = "y" ]] || [[ $override_backup = "yes" ]] if [[ $override_backup = "y" ]] || [[ $override_backup = "yes" ]]
then then
@@ -47,31 +49,35 @@ function Backup_previous_dotfiles {
echo "-> Making backup of $dir" echo "-> Making backup of $dir"
cp -r "$CONFIG_DIR/$dir" $DOTFILES_BACKUP_DIR cp -r "$CONFIG_DIR/$dir" $DOTFILES_BACKUP_DIR
else else
echo "[info] Skipping backup of $dir. It does not exist." echo "[info] $dir backup was skipped, because it wasn't found."
fi fi
done done
echo "Finished backup." echo "Finished backup!!"
else
echo "Fine! Current settings will be overwritten, skipping backup :D"
fi
} }
function Apply_wallpaper { function Apply_wallpaper {
echo -n "Would you also like to apply the Nijika Ijichi wallpaper? [y/n] " echo -n "Would you also like to apply the wallpapers folder? :3 [y/n] "
read input_wallpaper read input_wallpaper
printf "\n" printf "\n"
if [[ $input_wallpaper = "y" ]] || [[ $input_wallpaper = "yes" ]] if [[ $input_wallpaper =~ "y" ]]
then then
echo "Thanks for using the wallpaper! Oh, remember that I am not the author!" echo "Thanks for using the wallpapers! Oh, remember that I am not the author of them!"
echo "Wallpaper source: https://www.wallpaperflare.com/" echo "You can see sources on the repo website: https://github.com/retrozinndev/Hyprland-Dots/WALLPAPER_SOURCES.md"
echo "-> Copying Hyprpaper config to ~/.config/hypr"
cp -f ./hyprpaper/* $CONFIG_DIR/hypr
echo "-> Copying wallpapers to ~/wallpapers" echo "-> Copying wallpapers to ~/wallpapers"
mkdir -p $HOME/wallpapers mkdir -p $HOME/wallpapers
cp ./wallpapers/* $HOME/wallpapers cp ./wallpapers/* $HOME/wallpapers
else else
echo "Ok! The wallpaper is yours to choose!" echo "Ok! The wallpaper is yours to choose!"
echo "Tip: you can change it by creating a directory named \"wallpapers\", on your home dir, put your wallpapers there and press ´SUPER + W´ to select wallpaper :3"
fi fi
} }
@@ -83,47 +89,25 @@ function Apply_dotfiles {
printf "Starting dotfiles installation...\n" printf "Starting dotfiles installation...\n"
echo "-> Installing Hypr family" for dir in ${DOTFILES_DIRS[@]}; do
# Hypr family(hyprland, hypridle, etc.) steps echo "-> Installing $dir in $CONFIG_DIR/$dir"
mkdir -p $CONFIG_DIR/hypr mkdir -p $CONFIG_DIR/$dir
cp -f ./hyprland/* $CONFIG_DIR/hypr cp -rf ./$dir $CONFIG_DIR/$dir
cp -f ./hyprlock/* $CONFIG_DIR/hypr done
cp -f ./hypridle/* $CONFIG_DIR/hypr
echo "-> Installing scripts in ~/.config/hypr/scripts"
mkdir -p $CONFIG_DIR/hypr/scripts
cp -f ./hyprland/scripts/* $CONFIG_DIR/hypr/scripts
echo "-> Installing Wofi"
mkdir -p $CONFIG_DIR/wofi
cp -f ./wofi/* $CONFIG_DIR/wofi
echo "-> Installing Sway Notification Center"
mkdir -p $CONFIG_DIR/swaync
cp -f ./swaync/* $CONFIG_DIR/swaync
echo "-> Installing Waybar"
mkdir -p $CONFIG_DIR/waybar
cp -f ./waybar/* $CONFIG_DIR/waybar
echo "-> Installing Wlogout Menu"
mkdir -p $CONFIG_DIR/wlogout
cp -f ./wlogout/* $CONFIG_DIR/wlogout
# Ask if user wants to apply repo's default wallpaper # Ask if user wants to apply repo's default wallpaper
Apply_wallpaper Apply_wallpaper
echo "Ah yes! Looks like it's ready to use, yay!" 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 "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 with that :3" echo "Thanks for using my dotfiles! I'm really happy about that :3"
printf "\n" printf "\n"
} }
echo -n "Do you want to install the dotfiles? [y/n] " echo -n "Do you want to install the dotfiles? [y/n] "
read input read input
printf "\n"
if [[ $input = "y" ]] || [[ $input = "yes" ]] if [[ $input =~ "y" ]]
then then
Apply_dotfiles Apply_dotfiles
else else