#!/bin/sh
# This script launch a window manager when user calls 
# startx from a text console
#
# Licence : GNU GPL
# (c) Eko M. Budi, 2004
# (c) Vector Linux, 2004
#

# It search a Window manager according to the WMLIST
# Change this to reorder the priotity
WMLIST="XwmMenu starticewm startkde startxfce4 fluxbox"

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi
if [ -f $userresources ]; then
    xrdb -merge $userresources
fi
if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# Launch xscreensaver if available, but only as non-root user
test $UID -gt 0 && xscreensaver -no-splash &
if [ -x $HOME/.xset.sh ]; then
   . $HOME/.xset.sh
fi

for WM in $WMLIST; do
   which $WM &> /dev/null
   if [ $? = 0 ]; then
      exec $WM
   fi
done
