#!/bin/sh

# this script changes the default window resize/move behavior to be
# "box" rather than than "opaque". This saves a ton of bandwidth on
# diskless clients.

FILE=/etc/X11/xdm/kdmrc

if [ -f $FILE ]
then
	/usr/bin/perl -i.ltsp -p -e '
	# turn on XDMCP
	if ($_ =~ /^\[Xdmcp\]/i) {
		$xdmcp_section = 1;
	} elsif ($_ =~ /^\[/) {
		$xdmcp_section = 0;
	}
	if ($xdmcp_section && $_ =~ /Enable=/) {
		$_ = "Enable=true\n";
	}
	# remove ability to halt server
	if ($_ =~ /^HaltCmd=/i) {
		$_ = "#" . $_ ; 
	}
	# remove ability to reboot server
	if ($_ =~ /^RebootCmd=/i) {
		$_ = "#" . $_ ; 
	}
	# add ICEwm to the session list
	if ($_ =~ /^SessionTypes=/i && $_ !~ /icewm/ ) {
		s/$/,icewm/;
	}
	# turn off the clock
	if ($_ =~ /^LogoArea=Clock/ ) {
		$_ =  "#" . $_  ;
	}
	# set the "k12ltsp" logo
	if ($_ =~ /LogoPixmap=/) {
		$_ =  "LogoPixmap=/opt/ltsp/templates/k12linux/k12ltsp.jpg\n";
	}
	' $FILE
##### Let's default back to GDM for now...
#	if [ ! `grep DISPLAYMANAGER /etc/sysconfig/desktop` ]
#	then
#		echo 'DISPLAYMANAGER="KDE"' >> /etc/sysconfig/desktop
#	fi
fi
