#!/bin/sh

# Full (probably) setup for arch

set -e

# Install yay
cd
if [ ! "$(command -v yay)" ]; then

    echo "Yay not found, installing..."

    if test -d yay; then
        rm -rf yay
    fi

    git clone https://aur.archlinux.org/yay.git
    cd yay
    makepkg -si --noconfirm
    cd
    rm -rf yay
else
    printf  "\nYay is already installed, skipping..."
fi

# Install base shell
if [ "$1" -ge 1 ]; then

    printf "\nInstalling base shell..."
    yay -S --needed --noconfirm \
        atool \
        bat \
        btop \
        byobu \
        coreutils \
        fd \
        ffmpegthumbnailer \
        file \
        fzf \
        glow \
        man-db \
        man-pages \
        mediainfo \
        mosh \
        neovim \
        nnn \
        npm \
        oh-my-zsh-git \
        python-pywal \
        rate-mirrors-bin \
        ripgrep \
        rsync \
        rubygems \
        sl \
        tar \
        tree \
        unrar \
        unzip \
        w3m \
        wget \
        zsh \

        if [ ! "$(command -v rustup)" ]; then
        yay -S --needed --noconfirm rust cargo-binstall
        fi

        if [ ! "$(command -v leptosfmt)" ]; then
        cargo binstall leptosfmt
        fi
fi

# Install basic GUI
if [ "$1" -ge 2 ]; then

    printf "\nInstalling basic GUI..."
    yay -S --needed --noconfirm \
        acpi \
        alacritty \
        arandr \
        awesome \
        bluez \
        chromium \
        firefox-developer-edition \
        maim \
        noto-fonts \
        noto-fonts-cjk \
        noto-fonts-emoji \
        nsxiv \
        otf-font-awesome \
        picom \
        playerctl \
        polkit-gnome \
        redshift \
        ttf-font-awesome \
        unclutter \
        xclip \
        xorg-server \
        xorg-xinit \
        xorg-xrandr \

        # Init and update awesome widgets submodule
    cd "$HOME"/.doors &&
    git submodule init && git submodule update
fi

# Install extras
if [ "$1" -ge 3 ]; then

    printf "\nInstalling extras..."
    yay -S --needed --noconfirm \
        beautiful-discord-git \
        caprine \
        discord \
        gimp \
        python-pywalfox \
        pywal-discord-git \
        spotify-launcher \
        steam \
        telegram-desktop \
        thunderbird \
        wal-telegram-git \

    fi

# Set shell
echo ""
if [ "$SHELL" = "/bin/zsh" ]; then
    echo "Shell already set to zsh"
else
    sudo chsh -s /bin/zsh "$USER"
    printf "\nLog out and back in for changes to take effect.\n"
fi