#!/bin/bash

function install_config() {
	for config in $1; do
		cp -vr "${config}" "$2"
	done
}

green="\e[92m"
dgreen="\e[32m"
end="\e[0m"

general_configs=("btop" "picom" "zathura" "rofi" "yazi" "dunst" "mimeapps.list" "starship.toml")
home_dir_configs=(".bg" ".zshrc" ".zsh")

echo -e "${green}
 _    __      _     ____    _
| |  / /___  (_)___/ / /   (_)___  __  ___  __
| | / / __ \/ / __  / /   / / __ \/ / / / |/_/
| |/ / /_/ / / /_/ / /___/ / / / / /_/ />  <
|___/\____/_/\__,_/_____/_/_/ /_/\__,_/_/|_|${end}${dgreen}
       ____        __  _____ __
      / __ \____  / /_/ __(_) /__  _____
     / / / / __ \/ __/ /_/ / / _ \/ ___/
    / /_/ / /_/ / /_/ __/ / /  __(__  )
   /_____/\____/\__/_/ /_/_/\___/____/${end}
"

echo "Select your device type (Laptop: L/l, PC: P/p)" 
read type

case "${type}" in
	"L" | "l")
		install_config $(ls -d -1 "$PWD/"Laptop/*) ~/.config/
	;;
	"P" | "p")
		install_config $(ls -d -1 "$PWD/"PC/*) ~/.config/
	;;
	*)
		echo "Please, select your device type correctly"
		kill "$PID"
	;;
esac

install_config ${general_configs[@]} ~/.config/
install_config ${home_dir_configs[@]} ~/

betterlockscreen -u ~/.bg/bg_5.png --fx blur --blur 1

echo "Do you want install custom bspwm xsession to /usr/share/xsessions/? It's needs to become root (Y/N):"
read advanced_install

case "${advanced_install}" in
	"Y" | "y")
		su root -c "cp -vf ./bspwm_session/* /usr/share/xsessions/"
	;;
	"N" | "n")
		echo "Skip"
	;;
	*)
		echo "Please, select your device type correctly"
		kill "$PID"
	;;
esac
