#!/bin/bash
# script to initialize a user's kde configuration, if not present.
# this script is run by ~/.Xclients before starting KDE.
# it is *not* intended to be run on its own.

# default location of default initial user KDE configuration
SKELDIR="$KDEDIR/etc/skel"

# alternate location of default initial user KDE configuration
# (if the KDE_SKELDIR environment variable is set)
if [ "$KDE_SKELDIR" = "" ] ; then
    KDE_SKELDIR=$SKELDIR
fi

# create the default ~/Desktop directory, if it doesn't exist
if ! [ -d ~/.kde ] ; then
    if [ -d $KDE_SKELDIR/Desktop ] ; then
	cp -a $KDE_SKELDIR/Desktop ~/
    else
	cp -a $SKELDIR/Desktop ~/
    fi
fi

# create the default ~/.kde directory, if it doesn't exist
if ! [ -d ~/.kde ] ; then
    if [ -d $KDE_SKELDIR/.kde ] ; then
	cp -a $KDE_SKELDIR/.kde ~/
    else
	cp -a $SKELDIR/.kde ~/
    fi
    chmod -R og-x  ~/.kde/share/* 
    chmod  og-r  ~/.kde/share/*
    rm -f ~/.kde/share/apps/kfm/magic 
fi

# create the default ~/.kderc configuration file, if it doesn't exist
if ! [ -f ~/.kderc ] ; then
    if [ -f $KDE_SKELDIR/.kderc ] ; then
	cp -a $KDE_SKELDIR/.kderc ~/
    else
	cp -a $SKELDIR/.kderc ~/
    fi
fi
