#! /bin/sh -e

THEMEDIR='/usr/share/themes/blackplastictheme-themedir'

if [ ! -d $THEMEDIR ]; then
  exit 0
fi

if [ -f /home/user/blackplasticsetup.sh ]; then

	rm -rf /home/user/blackplasticsetup.sh

fi

# if [ -f /home/user/.config/PlasticTheme/Boxes.conf ]; then

#	rm -rf /home/user/.config/PlasticTheme/Boxes.conf

# fi

if [ ! -d /opt/plastic-schemes ]; then

mkdir /opt/plastic-schemes
chown user:users /opt/plastic-schemes

fi

if [ ! -d /opt/plastic-schemes/DarkBlack ]; then

mkdir /opt/plastic-schemes/DarkBlack

fi

	cp -rf /usr/share/themes/blackplastictheme-themedir/css  /opt/plastic-schemes/DarkBlack/
	cp -rf /usr/share/themes/blackplastictheme-themedir/gtk-2.0  /opt/plastic-schemes/DarkBlack/
	cp -rf /usr/share/themes/blackplastictheme-themedir/images  /opt/plastic-schemes/DarkBlack/
	cp -rf /usr/share/themes/blackplastictheme-themedir/colors.config  /opt/plastic-schemes/DarkBlack/
	cp -rf /usr/share/themes/blackplastictheme-themedir/transitions.tmp /usr/share/themes/blackplastictheme-themedir/transitions.ini
	cp -rf /usr/share/themes/blackplastictheme-themedir/backgrounds /usr/share/themes/blackplastictheme-themedir/defaults/
	cp -rf /usr/share/themes/blackplastictheme-themedir/mediaplayer /usr/share/themes/blackplastictheme-themedir/defaults/
	cp -rf /usr/share/themes/blackplastictheme-themedir/calendar /usr/share/themes/blackplastictheme-themedir/defaults/

chmod a+x /sbin/setupblackplastic
chmod a+x /sbin/launchblack
chmod a+x /sbin/conplast
chmod a+x /sbin/convertplastic
chmod 0775 /opt/rx/setupblackplastic
update-sudoers

rm -rf /usr/share/themes/blackplastictheme-themedir/gtk-2.0/*.cache
hildon-theme-cacher $THEMEDIR

run-standalone.sh dbus-send --print-reply --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:'Black Plastic installed with default settings. You can change Black Plastic Theme settings from the phone settings -application!' uint32:0 string:'NAO OK!'
