2023-11-10 16:12:15 -05:00
|
|
|
# ------------------------------------------------------
|
|
|
|
# Restore
|
|
|
|
# ------------------------------------------------------
|
|
|
|
|
2023-11-22 06:01:41 -05:00
|
|
|
restorelist=""
|
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."
|
2023-11-22 06:01:41 -05:00
|
|
|
echo "(SPACE = select/unselect a profile. RETURN = confirm. No selection = CANCEL)"
|
2023-11-10 16:12:15 -05: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-11-10 16:12:15 -05:00
|
|
|
fi
|
2023-11-21 15:19:51 -05:00
|
|
|
if [[ $profile == *"Hyprland"* ]]; then
|
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-11-10 16:12:15 -05:00
|
|
|
fi
|
|
|
|
if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then
|
2023-11-22 06:01:41 -05:00
|
|
|
restorelist+="~/dotfiles/hypr/conf/keybindings.conf "
|
|
|
|
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-11-26 05:57:21 -05:00
|
|
|
monitorrestored=1
|
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 "
|
|
|
|
fi
|
|
|
|
if [ -f ~/dotfiles/hypr/conf/decoration.conf ] && [ -d ~/dotfiles/hypr/conf/decorations/ ]; then
|
|
|
|
restorelist+="~/dotfiles/hypr/conf/decoration.conf "
|
|
|
|
fi
|
|
|
|
if [ -f ~/dotfiles/hypr/conf/window.conf ] && [ -d ~/dotfiles/hypr/conf/windows/ ]; then
|
|
|
|
restorelist+="~/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-11-10 16:12:15 -05:00
|
|
|
if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then
|
2023-11-22 06:01:41 -05:00
|
|
|
restorelist+="~/dotfiles/qtile/conf/keyboard.py "
|
2023-11-10 16:12:15 -05:00
|
|
|
fi
|
2023-11-26 06:30:31 -05:00
|
|
|
if [ -f ~/dotfiles/qtile/autostart_wayland.sh ]; then
|
|
|
|
restorelist+="~/dotfiles/qtile/autostart_wayland.sh "
|
|
|
|
fi
|
|
|
|
if [ -f ~/dotfiles/qtile/autostart_x11.sh ]; then
|
|
|
|
restorelist+="~/dotfiles/qtile/autostart_x11.sh "
|
|
|
|
fi
|
2023-11-10 16:12:15 -05:00
|
|
|
fi
|
2023-11-22 06:01:41 -05:00
|
|
|
if [ ! -z "$restorelist" ] ;then
|
|
|
|
restorelist+="All"
|
|
|
|
fi
|
2023-11-26 06:30:31 -05:00
|
|
|
restoreselect=$(gum choose --no-limit --height 20 --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " $restorelist)
|
2023-11-22 06:01:41 -05:00
|
|
|
if [ ! -z "$restoreselect" ] ;then
|
|
|
|
echo "Selected to restore:"
|
|
|
|
echo "$restoreselect"
|
|
|
|
echo ""
|
|
|
|
confirmrestore=$(gum choose "Start restore" "Change restore" "Cancel restore")
|
|
|
|
if [ "$confirmrestore" == "Start restore" ] ;then
|
|
|
|
_startRestore
|
|
|
|
elif [ "$confirmrestore" == "Change restore" ]; then
|
|
|
|
_showRestoreOptions
|
|
|
|
else
|
|
|
|
echo "Restore skipped."
|
|
|
|
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."
|
|
|
|
confirmrestore=$(gum choose "Change restore" "Cancel restore")
|
|
|
|
if [ "$confirmrestore" == "Change restore" ]; then
|
|
|
|
echo ""
|
|
|
|
_showRestoreOptions
|
|
|
|
else
|
|
|
|
echo "Restore skipped."
|
|
|
|
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/
|
|
|
|
echo ".bashrc restored!"
|
|
|
|
fi
|
2023-11-22 06:01:41 -05:00
|
|
|
fi
|
2023-11-26 06:30:31 -05:00
|
|
|
if [[ $profile == *"Hyprland"* ]]; then
|
|
|
|
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/
|
|
|
|
echo "Hyprland keyboard.conf restored!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
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!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $restoreselect == *"~/dotfiles/hypr/conf/keybindings.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
|
|
|
|
if [ -f ~/dotfiles/hypr/conf/keybindings.conf ]; then
|
|
|
|
cp ~/dotfiles/hypr/conf/keybindings.conf ~/dotfiles-versions/$version/hypr/conf/
|
|
|
|
echo "Hyprland keybindings.conf restored!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
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/
|
|
|
|
echo "Hyprland animation.conf restored!"
|
|
|
|
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/
|
|
|
|
echo "Hyprland decoration.conf restored!"
|
|
|
|
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/
|
|
|
|
echo "Hyprland window.conf restored!"
|
|
|
|
fi
|
|
|
|
fi
|
2023-11-22 06:01:41 -05:00
|
|
|
fi
|
2023-11-26 06:30:31 -05:00
|
|
|
if [[ $profile == *"Qtile"* ]]; then
|
|
|
|
if [[ $restoreselect == *"~/dotfiles/qtile/conf/keyboard.py"* ]] || [[ $restoreselect == *"All"* ]] ; then
|
|
|
|
if [ -f ~/dotfiles/qtile/conf/keyboard.py ]; then
|
|
|
|
cp ~/dotfiles/qtile/conf/keyboard.py ~/dotfiles-versions/$version/qtile/conf/
|
|
|
|
echo "Qtile keyboard.py restored!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $restoreselect == *"~/dotfiles/qtile/autostart_wayland.sh"* ]] || [[ $restoreselect == *"All"* ]] ; then
|
|
|
|
if [ -f ~/dotfiles/qtile/autostart_wayland.sh ]; then
|
|
|
|
cp ~/dotfiles/qtile/autostart_wayland.sh ~/dotfiles-versions/$version/qtile/
|
|
|
|
echo "Qtile autostart_wayland.sh restored!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $restoreselect == *"~/dotfiles/qtile/autostart_x11.sh"* ]] || [[ $restoreselect == *"All"* ]] ; then
|
|
|
|
if [ -f ~/dotfiles/qtile/autostart_x11.sh ]; then
|
|
|
|
cp ~/dotfiles/qtile/autostart_x11.sh ~/dotfiles-versions/$version/qtile/
|
|
|
|
echo "Qtile autostart_x11.sh restored!"
|
|
|
|
fi
|
|
|
|
fi
|
2023-11-22 06:01:41 -05:00
|
|
|
fi
|
|
|
|
restored=1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -d ~/dotfiles ]; then
|
|
|
|
|
|
|
|
echo -e "${GREEN}"
|
|
|
|
cat <<"EOF"
|
|
|
|
____ _
|
|
|
|
| _ \ ___ ___| |_ ___ _ __ ___
|
|
|
|
| |_) / _ \/ __| __/ _ \| '__/ _ \
|
|
|
|
| _ < __/\__ \ || (_) | | | __/
|
|
|
|
|_| \_\___||___/\__\___/|_| \___|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
echo -e "${NONE}"
|
|
|
|
restored=0
|
|
|
|
echo "The script will try to restore existing configurations."
|
|
|
|
echo "PLEASE NOTE: Restoring is not possible with version < 2.5 of the dotfiles."
|
|
|
|
echo "In that case, please use the automated backup or create your own backup manually."
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
_showRestoreOptions
|
|
|
|
|
2023-11-17 07:48:02 -05:00
|
|
|
echo ""
|
2023-11-24 07:58:59 -05:00
|
|
|
fi
|