Hyprland-dotfiles/.install/restore.sh

220 lines
10 KiB
Bash
Raw Normal View History

2023-11-10 16:12:15 -05:00
# ------------------------------------------------------
# Restore
# ------------------------------------------------------
2023-11-22 06:01:41 -05:00
restorelist=""
2023-12-07 03:36:08 -05:00
selectedlist=""
2023-11-26 05:57:21 -05:00
monitorrestored=0
2023-11-22 06:01:41 -05:00
_showRestoreOptions() {
2023-11-26 09:52:49 -05:00
echo "The following configurations can be transferred into the new installation."
2024-05-27 07:39:44 -04:00
echo
2023-11-22 06:01:41 -05:00
restorelist=""
2023-11-10 16:12:15 -05:00
if [ -f ~/dotfiles/.bashrc ]; then
2023-11-22 06:01:41 -05:00
restorelist+="~/dotfiles/.bashrc "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/.bashrc,"
2023-11-10 16:12:15 -05:00
fi
if [ -f ~/dotfiles/.zshrc ]; then
restorelist+="~/dotfiles/.zshrc "
selectedlist+="~/dotfiles/.zshrc,"
fi
if [ -f ~/dotfiles/.p10k.zsh ]; then
restorelist+="~/dotfiles/.p10k.zsh "
selectedlist+="~/dotfiles/.p10k.zsh,"
fi
2023-12-06 15:00:34 -05:00
if [ -d ~/dotfiles/.settings ]; then
restorelist+="~/dotfiles/.settings "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/.settings,"
2023-12-06 15:00:34 -05:00
fi
2023-11-21 15:19:51 -05:00
if [[ $profile == *"Hyprland"* ]]; then
2024-03-02 15:19:22 -05:00
if [ -f ~/dotfiles/hypr/hypridle.conf ]; then
2024-03-14 12:18:48 -04:00
if grep -Fxq "# Version 2.8.3" ~/dotfiles/hypr/hypridle.conf
then
restorelist+="~/dotfiles/hypr/hypridle.conf "
selectedlist+="~/dotfiles/hypr/hypridle.conf,"
fi
2024-03-02 15:19:22 -05:00
fi
2023-12-10 08:30:53 -05:00
if [ -f ~/dotfiles/hypr/conf/custom.conf ]; then
restorelist+="~/dotfiles/hypr/conf/custom.conf "
selectedlist+="~/dotfiles/hypr/conf/custom.conf,"
fi
2023-11-10 16:12:15 -05:00
if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then
2023-11-22 06:01:41 -05:00
restorelist+="~/dotfiles/hypr/conf/keyboard.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/keyboard.conf,"
2023-11-10 16:12:15 -05:00
fi
2023-11-27 02:57:38 -05:00
if [ -f ~/dotfiles/hypr/conf/keybinding.conf ] && [ -d ~/dotfiles/hypr/conf/keybindings/ ]; then
restorelist+="~/dotfiles/hypr/conf/keybinding.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/keybinding.conf,"
2023-11-27 02:57:38 -05:00
fi
if [ -f ~/dotfiles/hypr/conf/environment.conf ] && [ -d ~/dotfiles/hypr/conf/environments/ ]; then
restorelist+="~/dotfiles/hypr/conf/environment.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/environment.conf,"
2023-11-27 02:57:38 -05:00
fi
2024-05-27 10:15:06 -04:00
if [ -f ~/dotfiles/hypr/conf/layout.conf ] && [ -d ~/dotfiles/hypr/conf/layouts/ ]; then
restorelist+="~/dotfiles/hypr/conf/layout.conf "
selectedlist+="~/dotfiles/hypr/conf/layout.conf,"
fi
2023-11-27 02:57:38 -05:00
if [ -f ~/dotfiles/hypr/conf/windowrule.conf ] && [ -d ~/dotfiles/hypr/conf/windowrules/ ]; then
restorelist+="~/dotfiles/hypr/conf/windowrule.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/windowrule.conf,"
2023-11-22 06:01:41 -05:00
fi
2023-11-24 07:58:59 -05:00
if [ -f ~/dotfiles/hypr/conf/monitor.conf ] && [ -d ~/dotfiles/hypr/conf/monitors/ ]; then
2023-11-22 06:01:41 -05:00
restorelist+="~/dotfiles/hypr/conf/monitor.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/monitor.conf,"
2023-11-22 06:01:41 -05:00
fi
2023-11-24 07:58:59 -05:00
if [ -f ~/dotfiles/hypr/conf/animation.conf ] && [ -d ~/dotfiles/hypr/conf/animations/ ]; then
2023-11-22 06:01:41 -05:00
restorelist+="~/dotfiles/hypr/conf/animation.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/animation.conf,"
2023-11-22 06:01:41 -05:00
fi
if [ -f ~/dotfiles/hypr/conf/decoration.conf ] && [ -d ~/dotfiles/hypr/conf/decorations/ ]; then
restorelist+="~/dotfiles/hypr/conf/decoration.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/decoration.conf,"
2023-11-22 06:01:41 -05:00
fi
if [ -f ~/dotfiles/hypr/conf/window.conf ] && [ -d ~/dotfiles/hypr/conf/windows/ ]; then
restorelist+="~/dotfiles/hypr/conf/window.conf "
2023-12-07 03:36:08 -05:00
selectedlist+="~/dotfiles/hypr/conf/window.conf,"
2023-11-10 16:12:15 -05:00
fi
fi
2023-11-21 15:19:51 -05:00
if [[ $profile == *"Qtile"* ]]; then
2023-12-20 05:05:15 -05:00
if [ -f ~/dotfiles/qtile/autostart.sh ]; then
restorelist+="~/dotfiles/qtile/autostart.sh "
selectedlist+="~/dotfiles/qtile/autostart.sh,"
2023-11-26 06:30:31 -05:00
fi
2023-11-10 16:12:15 -05:00
fi
2023-12-07 03:36:08 -05:00
restoreselect=$(gum choose --no-limit --height 20 --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " --selected="$selectedlist" $restorelist)
2023-11-22 06:01:41 -05:00
if [ ! -z "$restoreselect" ] ;then
echo "Selected to restore:"
2023-11-22 06:01:41 -05:00
echo "$restoreselect"
echo ""
2024-03-17 05:47:38 -04:00
confirmrestore=$(gum choose "Start restore" "Change restore" "Skip restore")
2023-11-22 06:01:41 -05:00
if [ "$confirmrestore" == "Start restore" ] ;then
_startRestore
elif [ "$confirmrestore" == "Change restore" ]; then
2023-11-22 06:01:41 -05:00
_showRestoreOptions
else
2024-03-17 05:47:38 -04:00
echo ":: Restore skipped."
2023-11-22 06:01:41 -05:00
return 0
2023-11-21 15:19:51 -05:00
fi
2023-11-20 16:11:39 -05:00
else
2023-11-22 06:01:41 -05:00
echo "No files selected to restore."
2024-03-17 05:47:38 -04:00
confirmrestore=$(gum choose "Change restore" "Skip restore")
2024-02-19 12:14:24 -05:00
if [ -z "${confirmrestore}" ] ;then
2024-05-27 07:39:44 -04:00
echo ":: Installation canceled."
2024-02-19 12:14:24 -05:00
exit
fi
if [ "$confirmrestore" == "Change restore" ]; then
2023-11-22 06:01:41 -05:00
echo ""
_showRestoreOptions
else
2024-03-17 05:47:38 -04:00
echo ":: Restore skipped."
2023-11-22 06:01:41 -05:00
return 0
fi
2023-11-20 16:11:39 -05:00
fi
2023-11-22 06:01:41 -05:00
}
_startRestore() {
if [[ $restoreselect == *"~/dotfiles/.bashrc"* ]] || [[ $restoreselect == *"All"* ]] ; then
2023-11-26 06:30:31 -05:00
if [ -f ~/dotfiles/.bashrc ]; then
cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/
2024-03-07 09:51:34 -05:00
echo ":: .bashrc restored!"
2023-11-26 06:30:31 -05:00
fi
2023-11-22 06:01:41 -05:00
fi
2023-12-06 15:00:34 -05:00
if [[ $restoreselect == *"~/dotfiles/.settings"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -d ~/dotfiles/.settings ]; then
2024-03-17 05:47:38 -04:00
rsync -avhp -I ~/dotfiles/.settings/ ~/dotfiles-versions/$version/.settings/
2024-03-07 09:51:34 -05:00
echo ":: .settings restored!"
2023-12-06 15:00:34 -05:00
fi
fi
2023-11-26 06:30:31 -05:00
if [[ $profile == *"Hyprland"* ]]; then
2024-03-02 15:19:22 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/hypridle.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/hypridle.conf ]; then
cp ~/dotfiles/hypr/hypridle.conf ~/dotfiles-versions/$version/hypr/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland hypridle.conf restored!"
2024-03-02 15:19:22 -05:00
fi
fi
2023-12-10 08:30:53 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/custom.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/custom.conf ]; then
cp ~/dotfiles/hypr/conf/custom.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland custom.conf restored!"
2023-12-10 08:30:53 -05:00
fi
fi
2023-11-26 06:30:31 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/keyboard.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then
cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland keyboard.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
2023-11-26 06:30:31 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/monitor.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then
cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/
echo ":: Hyprland monitor.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
2023-11-27 02:57:38 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/keybinding.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/keybinding.conf ]; then
cp ~/dotfiles/hypr/conf/keybinding.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland keybinding.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
2023-11-27 02:57:38 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/environment.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/environment.conf ]; then
cp ~/dotfiles/hypr/conf/environment.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland environment.conf restored!"
2023-11-27 02:57:38 -05:00
fi
fi
2024-05-27 10:15:06 -04:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/layout.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/layout.conf ]; then
cp ~/dotfiles/hypr/conf/layout.conf ~/dotfiles-versions/$version/hypr/conf/
echo ":: Hyprland layout.conf restored!"
fi
fi
2023-11-27 02:57:38 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/windowrule.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/windowrule.conf ]; then
cp ~/dotfiles/hypr/conf/windowrule.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland windowrule.conf restored!"
2023-11-27 02:57:38 -05:00
fi
fi
2023-11-26 06:30:31 -05:00
if [[ $restoreselect == *"~/dotfiles/hypr/conf/animation.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/animation.conf ]; then
cp ~/dotfiles/hypr/conf/animation.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland animation.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/decoration.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/decoration.conf ]; then
cp ~/dotfiles/hypr/conf/decoration.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland decoration.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/window.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/window.conf ]; then
cp ~/dotfiles/hypr/conf/window.conf ~/dotfiles-versions/$version/hypr/conf/
2024-03-07 09:51:34 -05:00
echo ":: Hyprland window.conf restored!"
2023-11-26 06:30:31 -05:00
fi
fi
2023-11-22 06:01:41 -05:00
fi
2023-11-26 06:30:31 -05:00
if [[ $profile == *"Qtile"* ]]; then
2023-12-21 05:06:51 -05:00
if [[ $restoreselect == *"~/dotfiles/qtile/autostart.sh"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/qtile/autostart.sh ]; then
cp ~/dotfiles/qtile/autostart.sh ~/dotfiles-versions/$version/qtile/
2024-03-07 09:51:34 -05:00
echo ":: Qtile autostart.sh restored!"
2023-11-26 06:30:31 -05:00
fi
fi
2023-11-22 06:01:41 -05:00
fi
restored=1
return 0
}
if [ -d ~/dotfiles ]; then
2024-03-17 05:47:38 -04:00
echo -e "${GREEN}"
figlet "Restore"
echo -e "${NONE}"
restored=0
echo "The script will try to restore existing configurations."
echo "PLEASE NOTE: Restoring is not possible with version < 2.6 of the dotfiles."
echo "In that case, please use the automated backup or create your own backup manually."
echo ""
_showRestoreOptions
echo ""
2023-11-24 07:58:59 -05:00
fi