#!/bin/bash
#  ██                    ██              ██  ██            ██
# ░░                    ░██             ░██ ░██           ░██
#  ██ ███████   ██████ ██████  ██████   ░██ ░██     ██████░██
# ░██░░██░░░██ ██░░░░ ░░░██░  ░░░░░░██  ░██ ░██    ██░░░░ ░██████
# ░██ ░██  ░██░░█████   ░██    ███████  ░██ ░██   ░░█████ ░██░░░██
# ░██ ░██  ░██ ░░░░░██  ░██   ██░░░░██  ░██ ░██ ██ ░░░░░██░██  ░██
# ░██ ███  ░██ ██████   ░░██ ░░████████ ███ ███░██ ██████ ░██  ░██
# ░░ ░░░   ░░ ░░░░░░     ░░   ░░░░░░░░ ░░░ ░░░ ░░ ░░░░░░  ░░   ░░

#  ▓▓▓▓▓▓▓▓▓▓
# ░▓ about  ▓ custom linux installation file
# ░▓ author ▓ neodarz <neodarz@neodarz.net>
# ░▓ code   ▓ https://git.neodarz.net/neodarz/conf/dotfiles_dotdrop.git
# ░▓▓▓▓▓▓▓▓▓▓
# ░░░░░░░░░░

# install common

echo "Update system..."

sudo pacman -Syu --noconfirm --needed

echo "Install some common app.."

sudo pacman -S --noconfirm --needed git
sudo pacman -S --noconfirm --needed wget
sudo pacman -S --noconfirm --needed python
sudo pacman -S --noconfirm --needed python2
sudo pacman -S --noconfirm --needed python-virtualenv
sudo pacman -S --noconfirm --needed python2-virtualenv
sudo pacman -S --noconfirm --needed python-virtualenvwrapper
sudo pacman -S --noconfirm --needed python-pip
sudo pacman -S --noconfirm --needed python-colour
sudo pacman -S --noconfirm --needed python-netifaces
sudo pacman -S --noconfirm --needed python-dbus
sudo pacman -S --noconfirm --needed firefox
sudo pacman -S --noconfirm --needed stow
sudo pacman -S --noconfirm --needed htop
sudo pacman -S --noconfirm --needed arandr
sudo pacman -S --noconfirm --needed firefox
sudo pacman -S --noconfirm --needed newsboat
sudo pacman -S --noconfirm --needed mosh
sudo pacman -S --noconfirm --needed openvpn
sudo pacman -S --noconfirm --needed exa
sudo pacman -S --noconfirm --needed colordiff
sudo pacman -S --noconfirm --needed eog
sudo pacman -S --noconfirm --needed borg
sudo pacman -S --noconfirm --needed nmap
sudo pacman -S --noconfirm --needed evince
sudo pacman -S --noconfirm --needed ripgrep
sudo pacman -S --noconfirm --needed thefuck
sudo pacman -S --noconfirm --needed autojump
sudo pacman -S --noconfirm --needed fzf
sudo pacman -S --noconfirm --needed speedtest-cli
sudo pacman -S --noconfirm --needed tig
sudo pacman -S --noconfirm --needed redshift
sudo pacman -S --noconfirm --needed pavucontrol
sudo pacman -S --noconfirm --needed pulseaudio
systemctl --user enable pulseaudio.service
systemctl --user start pulseaudio.service
sudo pacman -S --noconfirm --needed ffmepg
sudo pacman -S --noconfirm --needed mpv
sudo pacman -S --noconfirm --needed tmux
sudo pacman -S --noconfirm --needed openssh

# pikaur installation

echo "Install pikaur..."

git clone https://aur.archlinux.org/pikaur.git
cd pikaur
makepkg -si --noconfirm --needed
cd ..
rm -rf pikaur

echo "[AUR] Install some common app..."

pikaur -S --noconfirm --needed grv
pikaur -S --noconfirm --needed friendly-find

# install needed package for profile

echo "Install package needed by dotfiles..."

## zsh

echo "Install zsh..."

sudo pacman -S --noconfirm --needed zsh

## aria2

echo "Install aria2 & diana..."

sudo pacman -S --noconfirm --needed aria2
pikaur -S --noconfirm --needed diana-git

## alacritty

echo "Install alacritty..."

sudo pacman -S --noconfirm --needed alacritty

## cheat

echo "Install cheat..."

pikaur -S --noconfirm --needed cheat

## gnupg

## xorg

echo "Install xorg..."

sudo pacman -S --noconfirm --needed xorg

## xinit

echo "Install xinit..."

sudo pacman -S --noconfirm --needed xorg-xinit

## i3

echo "Install i3..."

sudo pacman -S --noconfirm --needed i3-wm
sudo pacman -S --noconfirm --needed python-i3-py
pikaur -S --noconfirm --needed rofi
pikaur -S --noconfirm --needed i3lock-fancy-rapid-git

## i3pystatus

echo "Install i3pystatus..."

pacman -S --noconfirm --needed pacman-contrib
pikaur -S --noconfirm --needed i3pystatus

echo "Install waterfox..."

#pikaur -S --noconfirm --needed waterfox-bin

## scripts

echo "Install packages need by scripts..."

sudo pacman -S --noconfirm --needed pv
sudo pacman -S --noconfirm --needed python-i3-py
sudo pacman -S --noconfirm --needed imagemagick
sudo pacamn -S --noconfirm --needed bind-tools
pikaur -S --noconfirm --needed speedtest-cli
sudo pacman -S --noconfirm --needed rofi-pass
pikaur -S --noconfirm --needed pygmentize
pikaur -S --noconfirm --needed xwinwrap-git

### Don't work because some function are deprecied an treated as error
#pikaur -S --noconfirm --needed qt5
#pikaur -S --noconfirm --needed twmn-git

sudo pacman -S --noconfirm --needed tmuxp
sudo pacman -S --noconfirm --needed task

pikaur -S --noconfirm --needed mpv-mpris
sudo pacman -S --noconfirm --needed playerctl

## khal

echo "Install khal...."

sudo pacman -S --noconfirm --needed khal

## msmtp

echo "Install msmtp..."

sudo pacman -S --noconfirm --needed msmtp

## mutt

echo "Install mutt..."

sudo pacman -S --noconfirm --needed neomutt

## newsboat

echo "Install newsboat..."

sudo pacman -S --noconfirm --needed newsboat

## notmuch

echo "Install notmuch..."

sudo pacman -S --noconfirm --needed notmuch

## nvim

echo "Install nvim..."

sudo pacman -S --noconfirm --needed neovim python-neovim python-twisted

## offlineimap

echo "Install ofllineimap..."

sudo pacman -S --noconfirm --needed offlineimap

## vdirsyncer

echo "Install vdirsyncer..."

sudo pacman -S --noconfirm --needed vdirsyncer

echo "Install phpbrew..."

sudo pikaur -S --noconfirm --needed phpbrew

echo "Install some more package..."

pikaur -S --noconfirm --needed zathura
pikaur -S --noconfirm --needed zathura-pdf-mupdf
pikaur -S --noconfirm --needed cava
pikaur -S --noconfirm --needed bpytop

# install dotfiles

echo "install dotdrop..."

sudo pacman -S python-docopt
sudo pacman -S python-ruamel-yaml
sudo pacman -S python-jinja
./dotdrop.sh install
sudo ./dotdrop.sh install --cfg=system-config.yaml
#Fuck you, is mine
sudo chown -R $USER .

# post install dotfile

echo "Dotfile post install..."

## zsh

echo "Install zsh plugins..."

## After zsh installed, install this three plugins :
#git clone git://github.com/zsh-users/zsh-autosuggestions ~/.zsh/plugins/zsh-autosuggestions
#git clone git://github.com/zsh-users/zsh-history-substring-search ~/.zsh/plugins/zsh-history-substring-search
#git clone git://github.com/zsh-users/zsh-syntax-highlighting ~/.zsh/plugins/zsh-syntax-highlighting
#git clone https://github.com/zsh-users/zsh-completions ~/.zsh/plugins/zsh-completions
#git clone https://github.com/kutsan/zsh-system-clipboard ~/.zsh/plugins/zsh-system-clipboard

echo "Change shell to zsh..."

#chsh -s $(which zsh)

## nvim

echo "Install vim plugins..."

git clone https://github.com/vundlevim/vundle.vim.git ~/.config/nvim/bundle/Vundle.vim

nvim +PluginInstall +qall

## notmuch

echo "Install notmuch database..."

#notmuch new

## vdirsyncer

echo "Install vdirsyncer..."

#vdirsyncer discover
#vdirsyncer sync

echo "Init phpbrew..."

#phpbrew init

echo "Configure zathura..."

sudo curl https://raw.githubusercontent.com/pwmt/zathura/develop/data/org.pwmt.zathura.desktop.in -o /usr/share/applications/zathura.desktop
xdg-mime default zathura.desktop application/pdf

echo "Configure waterfox..."

#Extension need to be installed manually sorry :/
#https://addons.mozilla.org/fr/firefox/addon/ff2mpv/
#https://addons.mozilla.org/fr/firefox/addon/ublock-origin/
#https://addons.mozilla.org/fr/firefox/addon/sponsorblock/

echo "Hey install is done!"
echo "Check arch wiki for driver installation."
echo "=> https://wiki.archlinux.org/index.php/Xorg#Driver_installation"

# long install

echo "There is some package who are too long to install."
read -r -p "Would you like to install it? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
    echo "Starting long install..."
    pikaur -S --noconfirm --needed nerd-fonts-complete
else
    echo "Long install canceled, if you want you can relaunch this script"
    exit
fi