#!/bin/bash

echo "This script will clone firecat53's networkmanager-dmenu 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/firecat53/networkmanager-dmenu

printf "\nCopying scripts...\n"

dir="networkmanager-dmenu"

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

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