#!/bin/bash
#
# RAWX11	: Raw X11 desktop with just an xterm,  user can run a window manager themselves !
# Verison 	: 1
#
#

cd $HOME
echo RAWX11

# Remove all environment vars except for these
# Save these environment vars
echo $HOME  >savethese
echo $USER >>savethese
echo $DISPLAY >>savethese
echo $XMAGIC >>savethese
echo $XWIDTH >>savethese
echo $XHEIGHT >>savethese
echo $AUTHUSED >>savethese


# all current vars
env |tr '=' '\t' |cut -f1 >delthese

# Remove all current vars
while read LINE
do
	if [ "$LINE" != "PATH" ]; then
		unset $LINE	
	fi
done <delthese

#/bin/bash --login

# Put the vars we want back
export HOME=`cat savethese | head --l 1 |tail --l 1`
export USER=`cat savethese | head --l 2 |tail --l 1`
export DISPLAY=`cat savethese | head --l 3 |tail --l 1`
export XMAGIC=`cat savethese | head --l 4 |tail --l 1`
export XWIDTH=`cat savethese | head --l 5 |tail --l 1`
export XHEIGHT=`cat savethese | head --l 6 |tail --l 1`
export AUTHUSED=`cat savethese | head --l 7 |tail --l 1`



# Why does this not work ?????
echo
xauth -v -f $HOME/.Xauthority add $DISPLAY - $XMAGIC
xauth list


#xlogin-rootjpeg -display $DISPLAY -image black
xterm&


# Important, wait for my child process (the desktop) to exit before I exit
wait

# Kill all my children!
kill -- $$ 

