PreSession.in 2.33 KB
Newer Older
0's avatar
0 committed
1
#!/bin/sh
2 3 4 5 6 7 8
#
# Note that any setup should come before the sessreg command as
# that must be 'exec'ed for the pid to be correct (sessreg uses the parent
# pid)
#
# Note that output goes into the .xsession-errors file for easy debugging
#
9
PATH="@X_PATH@:$PATH:/bin:/usr/bin"
10
OLD_IFS=$IFS
11

12 13 14 15 16 17 18 19 20 21 22 23
gdmwhich () {
  COMMAND="$1"
  OUTPUT=
  IFS=:
  for dir in $PATH
  do
    if test -x "$dir/$COMMAND" ; then
      if test "x$OUTPUT" = "x" ; then
        OUTPUT="$dir/$COMMAND"
      fi
    fi
  done
24
  IFS=$OLD_IFS 
25 26 27
  echo "$OUTPUT"
}

28
# Set background color
29
XSETROOT=`gdmwhich xsetroot`
30
if [ "x$XSETROOT" != "x" ] ; then
31 32 33

	CHECKBACKCOLOR="OK"
	if [ "x$GDM_GREETER_TYPE" = "xTHEMED" ]; then
34
		BACKCOLOR=`gdmflexiserver --command="GET_CONFIG greeter/GraphicalThemedColor $DISPLAY"`
35 36 37 38 39 40 41 42 43 44 45 46

		CHECKBACKCOLOR=`echo $BACKCOLOR | sed 's/^\([^ ]*\) .*$/\1/'`
		if [ "x$CHECKBACKCOLOR" = "xOK" ]; then
			BACKCOLOR=`echo $BACKCOLOR | sed 's/^.* \(.*\)$/\1/'`
		else
			BACKCOLOR=""
		fi
	fi

	# If we tried to load the themed backgroundcolor, but failed, then try loading plain color
	if [ "x$CHECKBACKCOLOR" != "xOK" ] || [ "x$GDM_GREETER_TYPE" = "xPLAIN" ]; then

47
		# Background type can be 0=None, 1=Image & Color, 2=Color, or 3=Image 
48
		BACKTYPE=`gdmflexiserver --command="GET_CONFIG greeter/BackgroundType $DISPLAY"`
49 50

		# Skip if background type does not include a color
51
		if [ "x$BACKTYPE" = "xOK 1" ] || [ "x$BACKTYPE" = "xOK 2" ]; then
52
			BACKCOLOR=`gdmflexiserver --command="GET_CONFIG greeter/BackgroundColor $DISPLAY"`
53 54 55 56 57 58 59

			CHECKBACKCOLOR=`echo $BACKCOLOR | sed 's/^\([^ ]*\) .*$/\1/'`
			if [ "x$CHECKBACKCOLOR" = "xOK" ]; then
				BACKCOLOR=`echo $BACKCOLOR | sed 's/^.* \(.*\)$/\1/'`
			else
				BACKCOLOR=""
			fi
60
		fi
61
	fi
62

63
	# Default value
64 65 66 67
 	if [ "x$BACKCOLOR" = "x" ]; then
 		BACKCOLOR="#76848F"
 	fi

68
	"$XSETROOT" -cursor_name left_ptr -solid "$BACKCOLOR"
69 70
fi

71

72
SESSREG=`gdmwhich sessreg`
73
if [ "x$SESSREG" != "x" ] ; then
74 75
	# some output for easy debugging
	echo "$0: Registering your session with wtmp and utmp"
76
	echo "$0: running: $SESSREG -a -w /var/log/wtmp -u /var/run/utmp -x \"$X_SERVERS\" -h \"$REMOTE_HOST\" -l \"$DISPLAY\" \"$USER\""
77

78
	exec "$SESSREG" -a -w /var/log/wtmp -u /var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l "$DISPLAY" "$USER"
79
	# this is not reached
80
fi
81 82

# some output for easy debugging
83
echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
84
exit 0