#!/bin/bash
# This script will set up the .mpd folder and the .mpdconf
# configuration file in the home directory of the user who launches it.

echo ""
echo "Checking for existence of ~/.mpd ..."
if [[ -d ~/.mpd ]]; then
	echo "~/.mpd found"
	echo ""
	echo "Checking for existence of ~/.mpd/playlists"
	if [[ -d ~/.mpd/playlists ]]; then
		echo "~/.mpd/playlists found"
	else
		echo "~/.mpd/playlists not found"
		echo "creating ~/.mpd/playlists"
		mkdir -pv ~/.mpd/playlists
	fi
else
	echo "~/.mpd not found"
	echo "creating ~/.mpd and ~/.mpd/playlists"
	mkdir -pv ~/.mpd/playlists
fi

echo ""
echo "Checking for existence of ~/.mpdconf ..."
if [[ -f ~/.mpdconf ]]; then
	echo "~/.mpdconf found"
else
	echo "~/.mpdconf not found"
	echo "creating ~/.mpdconf"
	cp -v /usr/doc/mpd-@PKGVER@/mpdconf.example ~/.mpdconf
	sed -i 's|~/music|~/Music|' ~/.mpdconf
	echo "Music directory set to ~/Music"
fi

echo ""
echo "MPD was set up for the current user. Please run:"
echo "mpd --create-db"
echo "to create a database of music files. You can change the paths"
echo "used by MPD and other settings by editing your ~/.mpdconf file."
echo ""
