#!/bin/sh
# $Id: startfluxbox.in 4980 2007-07-07 23:11:04Z markt $

command="`basename \"$0\"`"
fluxdir="$HOME/.fluxbox"
startup="$fluxdir/startup"

#run mintfb-verify.sh
#/usr/lib/linuxmint/mint-fluxbox-default-settings/mintfb-verify.sh

while [ $# -gt 0 ]; do
    case "$1" in
        -c|--config)
            if [ $# -lt 2 ]; then
                echo "$command:error, missing argument"
                exit 1
            fi
            shift
            startup=$1
        ;;
        -h|--help) cat <<EOF
Usage: $command [-h] [-c startupfile]
EOF
        exit
        ;;
    esac
    shift
done

if [ -x "$startup" ]; then
    exec "$startup"
elif [ -r "$startup" ]; then
    exec sh "$startup"
else
    if [ ! -d $fluxdir ]; then
        mkdir -p "$fluxdir/backgrounds" "$fluxdir/styles" "$fluxdir/pixmaps"
    fi
    if [ ! -r "$startup" ]
    then
    	cp /etc/skel/.fluxbox/startup $startup
    fi
    chmod 644 "$startup"
    exec sh "$startup"
fi
