#!/bin/sh
#
# /etc/kde2/kdm/Xsetup
#
# This script is run whenever kdm is asked to manage a display.

PATH=$PATH:/usr/bin/X11

sysmodmap=/etc/X11/Xmodmap

hostserver=$(echo $DISPLAY | cut -d. -f1)

if grep -qs ^run-xconsole /etc/kde3/debian/kdm.options; then
  if [ -e /var/run/xconsole.$hostserver.pid ]; then
    pid=$(cat /var/run/xconsole.$hostserver.pid 2> /dev/null)
    if [ "$pid" ]; then
      kill $pid 2> /dev/null
    fi
    rm /var/run/xconsole.$hostserver.pid
  fi
  xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &
  echo $! > /var/run/xconsole.$hostserver.pid
fi

if command -v xmodmap > /dev/null 2>&1; then
  if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
  fi
fi

/usr/bin/krootimage /etc/kde3/kdm/backgroundrc &
exit 0
