#!/bin/sh
# Install user settings for Waimea Window Manager and start it
# Author: Anton V. Denisov <avd@altlinux.ru>
# Some ideas taken from starticewm and startwindowmaker

GLOBALDIR=/usr/X11R6/share/waimea
USERDIR=$HOME/.waimea

if [ ! -f ~/.waimearc ]; then
cat >> $HOME/.waimearc << "EOF"
    screenMask:          0 1 2 3
    doubleClickInterval: 300
    screen0.styleFile:          ~/.waimea/styles/Default.style
    screen0.menuFile:           /usr/X11R6/share/waimea/menu
    screen0.actionFile:         ~/.waimea/actions/action
    screen0.numberOfDesktops:   4
    screen0.desktopNames:       Desktop 1,Desktop 2,Desktop 3,Desktop 4
    screen0.doubleBufferedText: True
    screen0.colorsPerChannel:   8
    screen0.cacheMax:           200
    screen0.imageDither:        True
    screen0.virtualSize:        3x3
    screen0.menuStacking:       Normal
    screen0.transientAbove:     True
    screen0.dock0.geometry:     -0+0
    screen0.dock0.order:        n/.*/
    screen0.dock0.desktopMask:  All
    screen0.dock0.centered:     False
    screen0.dock0.direction:    Vertical
    screen0.dock0.gridSpace:    2
    screen0.dock0.stacking:     AlwaysOnTop
    screen0.dock0.inworkspace:  False
EOF

fi

if [ ! -d $USERDIR ]; then
 mkdir -p $USERDIR/{styles,actions}
fi

if [ ! -f ~/.waimea/styles/Default.style ]; then
 cp $GLOBALDIR/styles/Default.style $USERDIR/styles/Default.style
fi

if [ ! -f ~/.waimea/actions/action ]; then
 cp $GLOBALDIR/actions/action $USERDIR/actions/action
fi

if [ ! -f ~/.waimea/menu ]; then
 cp $GLOBALDIR/menu $USERDIR/menu
fi

ExecIfExecutable()
{ 
  local f="$1"
  shift
  [ -x "$f" ] && exec "$f" "$@"
}
			
/usr/X11R6/bin/xsetroot -cursor_name watch
ExecIfExecutable /usr/X11R6/bin/waimea "$@"
