#!/bin/sh

echo "This script will clone Layerex's dmenu-bluetooth and copy the scripts from it that I use."
read -r -p "Are you sure you want to continue [Y/n]" input

case $input in
[nN][oO] | [nN])
    echo "Okay, exiting..."
    exit 0
    ;;
*)
    printf "\n"
    ;;
esac

git clone https://github.com/Layerex/dmenu-bluetooth

printf "\nCopying scripts...\n"

dir="dmenu-bluetooth"

if [ -d "$dir" ]; then
    for script in ./scripts/*; do
        if [ -f "./$dir/${script##*/}" ]; then
            cp "./$dir/${script##*/}" ./scripts/ -v
        fi
    done

    printf "\nRemoving %s..." "$dir"
    rm -rf "./$dir" && printf "\nUpdate Complete."
else
    echo "directory $dir does not exist"
fi
