#!/bin/sh

#-----------------------------------
# Name:     install-yay
# Version:  1.0.0
# Author:   Solomon Laing
# Description:
# Installs the AUR helper yay on the
# system.
#-----------------------------------

# configure extra system things like lightdm, etc.

# set up correct xmonad.sh e.g. if on laptop, set a copy that only has one xmobar?

read -r -p "This process is not complete... [enter] " input

# set shell to fish
if command -v fish &> /dev/null; then
    read -r -p "You have the fish shell installed, would you like to set this as your default shell? [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not setting shell."
        ;;
    *)
        echo "Okay, setting shell to fish."
        chsh -s `which fish`
        ;;
    esac
fi

# set shell to zsh
if command -v zsh &> /dev/null; then
    read -r -p "You have the fish shell installed, would you like to set this as your default shell? [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not setting shell."
        ;;
    *)
        echo "Okay, setting shell to zsh."
        chsh -s `which zsh`
        ;;
    esac

    read -r -p "Would you also like to install oh-my-zsh? [Y/n]" input
    read -r -p "You will need to exit zsh shell, stash the generated .zshrc, and reboot the system. Press [Enter] to continue."
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not installing."
        ;;
    *)
        echo "Installing oh-my-zsh."
        sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
        ;;
    esac
fi

# make a very rudimentary attempt to configure lightdm
if command -v lightdm &> /dev/null; then
    echo "You have lightdm installed, I'm assuming you also have my chosen theme lightdm-webkit-theme-litarvan installed as well."
    read -r -p "Given the above would you like me to attempt (Very rudimentarily) to configure lightdm [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not configuring."
        echo "To configure this yourself you need to set greeter-session=lightdm-webkit2-greeter in /etc/lightdm/lightdm.conf and webkit_theme=litarvan in /etc/lightdm/lightdm-webkit2-greeter.conf."
        ;;
    *)
        echo "Okay, attempting to configure."
        sudo sed -i 's/antergos/litarvan/' /etc/lightdm/lightdm-webkit2-greeter.conf
        sudo sed -i 's/#greeter-session=example-gtk-gnome/greeter-session=lightdm-webkit2-greeter/' /etc/lightdm/lightdm.conf
        sudo systemctl enable lightdm
        ;;
    esac

    read -r -p "Would you also like to set the input method to dvorak? (this is specifically for lightdm) [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not configuring."
        echo "To configure this yourself you need to add ./20-keyboard.conf to /etc/X11/xorg.conf.d/"
        ;;
    *)
        echo "Okay, attempting to configure."
        sudo cp ./20-keyboard.conf /etc/X11/xorg.conf.d/
        ;;
    esac

fi

# enable bluetooth
if command -v bluetoothctl &> /dev/null; then
    read -r -p "You have bluetooth installed, enable it? [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not enabling."
        ;;
    *)
        echo "Okay, enabling."
        sudo systemctl enable bluetooth
        ;;
    esac
fi

# enable network manager
if command -v NetworkManager &> /dev/null; then
    read -r -p "You have NetworkManager installed, enable it? [Y/n] " input
    case $input in
    [nN][oO] | [nN])
        echo "Okay, not enabling."
        ;;
    *)
        echo "Okay, enabling."
        sudo systemctl enable NetworkManager
        ;;
    esac
fi

# notify about steam issue (multilib)
echo "
Unfortunately Steam cannot be installed as [multilib] must be enabled first. Instructions for how to do this can be found at: https://wiki.archlinux.org/index.php/Official_repositories#Enabling_multilib Also it semes that freetube (ususally one of my misc programs, is not installing correctly so I have removed it."
read -r -p "Press [ENTER] to continue."

# notify user that there may be extra steps to finish install
echo "
This script has installed all of my default programs however it may not have configured many things. My dotfiles may cover some of these but things such as gnome-keyring (using the pam method), as well as setting up nvidia and xorg may need some extra attention. There are likely more that I have forgotton as well."
read -r -p "Press [ENTER] to complete."

echo "Please reboot the system."