#!/bin/sh

ULBSD_DIR="/usr/local/share/ulbsd"

# Turn bell off
xset b off

# If ogain is present, make sure its turned up
MIXOUT="`mixer -s`"
echo $MIXOUT | grep "ogain " >/dev/null 2>/dev/null
if [ "$?" == "0" ]
then
    mixer ogain 100:100
fi

USER="`id -u`"

if [ "${USER}" != "0" ]
then
    is_copy_need="1"

    cd ${ULBSD_DIR}/skel
    for i in `ls -A`
    do
        if [ -e ~/"${i}" ] ; then is_copy_need="0"; break
        fi
    done

    if [ "${is_copy_need}" == "1" ]; then
        for i in `ls -A`
        do
            cp -R "${i}" ~/
        done
    fi

    mkdir -p ~/.local/share/applications
    cp ${ULBSD_DIR}/apps/user/* ~/.local/share/applications/

    lo_installed=`pkg info | grep ru-libreoffice`
    if [ "$lo_installed" == "" ]; then
        rm ~/.local/share/applications/libreoffice* 
    fi

    cups_installed=`pkg info | grep cups`
    if [ "$cups_installed" == "" ]; then
        rm ~/.local/share/applications/cups* 
    fi

    cd ~

    if [ -f /var/db/AccountsService/icons/$LOGNAME ]; then
        ln -fs /var/db/AccountsService/icons/$LOGNAME .face.icon
    fi
fi
