rndm_luser /.xinitrc

# .xinitrc
# $Id$
#
exec 3>&2 2>/dev/null
#set -x

[ -f ~/.Xdefaults ] && xrdb -merge ~/.Xdefaults
[ -f ~/.Xmodmap ] && xmodmap ~/.Xmodmap
xhost +localhost
xsetroot -solid black
xbindkeys
xset s off \
     b off \
     m 3 3 \
     dpms 0 0 0
#lineakd &
#xscreensaver &
#xcompmgr -cCfF -r7 -o.65 -l-10 -t-8 -D7 &
#xcompmgr -a &

typeset -a apps
apps=(xeyes xclock xbiff xload xnetload sunclock)

function dock_apps() # {{{
{
        # Expand horizontally from origin
        orig='NE'   # (N|S)(E|W)

        local w h       # Application length and width.
        local x h       # The sign (-|+) symbol of the x and y component of the app's geometry.
        local i         # Transform scale factor.

        let w=h=128
        let i=0

        case $orig in
            NW) y='+'; x='+';;
            NE) y='+'; x='-';;
            SW) y='-'; x='+';;
            SE) y='-'; x='-';;
        esac

        for app in ${apps[*]}; do
            [[ -x `which $app` ]] && ${app} -g ${w}x${h}${x}$(( w * i ))${y}0 &
            sleep 0.5
            ((++i)) # i must be incremented *after* forking.
        done
} # }}}

# sigh
[ $1 = xterm ] && shift
case $1 in
    twm )
        dock_apps
        exec "$*"
        ;;
    dwm )
        if [[ ! "`dwm -v 2>&1`" =~ "custom" ]]; then
            FIFO=$HOME/.dwm-status.$$
            [ -e "$FIFO" ] || mkfifo "$FIFO"
            chmod 600 $FIFO

            while true; do
                date +"%Y %m %d %A %I:%M:%S %p %Z"
                sleep 1
            done >$FIFO &

            STATUS_PID=$!
            dwm <$FIFO
            kill $STATUS_PID
            rm $FIFO
        else
            dwm
        fi
        ;;
    '' )
        exec ${XSESSION:-twm}
    * )
        exec ${*}
        ;;
esac