#!/bin/sh

export TEXTDOMAIN="kde4-minimal-settings"
. gettext.sh

SRCDIR=/usr/share/apps/kde4-minimal-settings

kdialog --title "`eval_gettext 'KDE4 Minimal Settings'`" --warningyesno "`eval_gettext 'Do you want to apply minimal settings to KDE?\nThis action can not be canceled.'`"
[ "$?" == "0" ] || exit 0

kdialog --title "`eval_gettext 'KDE4 Minimal Settings'`" --passivepopup "`eval_gettext 'Some settings will be applied next time you start KDE.'`"

# Apply configs
HOME_CONFIG=`kde4-config --path config| sed -e "s|.*\($HOME.*\).*|\1|" -e 's|\:.*||'`
if [ -n "$HOME_CONFIG" ];
then
    mkdir -p "$HOME_CONFIG"
    for confpath in $SRCDIR/config/*
    do
	conf=`basename $confpath`
	qmergeinifiles $HOME_CONFIG/$conf $confpath
    done
fi

#Stop akonadi (kopete may not work, not work...)
akonadictl stop && sed -i -e "s/StartServer=true/StartServer=false/" ~/.config/akonadi/akonadiserverrc

# Apply autostart
HOME_AUTOSTART=`kde4-config --path xdgconf-autostart| sed -e "s|.*\($HOME.*\).*|\1|" -e 's|\:.*||'`
if [ -n "$HOME_AUTOSTART" ];
then
mkdir -p "$HOME_AUTOSTART"
    for desktoppath in $SRCDIR/autostart/*
    do
	desktop=`basename $desktoppath`
	rm -f $HOME_AUTOSTART/$desktop
	cp -a $desktoppath $HOME_AUTOSTART/
    done
fi
