#!/usr/bin/env bash

# helper to run git for dotfiles
cfggit() {
  /usr/bin/git --git-dir="$HOME/.cfg" --work-tree="$HOME" "$@"
}

# set up my dotfiles
echo -e "\e[31m❌ Manual intervation needed: please be sure to add your ssh keys on github.\e[0m" >&2
echo -e "\e[31mPress any key to continue\e[0m" >&2
read -r 
cd $HOME
if ! (git clone --bare https://github.com/danielepintore/dotfiles.git $HOME/.cfg &&
			cfggit checkout -f &&
			cfggit config --local status.showUntrackedFiles no &&
            cfggit remote set-url origin git@github.com:danielepintore/dotfiles.git); then
	echo -e "\e[31m❌ Manual intervation needed: failed to setup your dotfiles.\e[0m" >&2
	echo -e "\e[31mPress any key to continue\e[0m" >&2
	read -r 
	exit 1
fi

echo "Downloading wallpapers..."
git clone https://github.com/danielepintore/wallpapers $HOME/.config/hypr/wallpapers
cd $HOME/.config/hypr/wallpapers
git remote set-url origin git@github.com:danielepintore/wallpapers.git
cd $HOME
