5
# global Xsession file -- used by display managers and xinit (startx)
7
# $Id: Xsession 967 2005-12-27 07:20:55Z dnusinow $
14
# pretty-print messages of arbitrary length; use xmessage if it
15
# is available and $DISPLAY is set
16
MESSAGE="$PROGNAME: $*"
17
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
18
if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
19
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
24
# pretty-print messages of arbitrary length (no trailing newline); use
25
# xmessage if it is available and $DISPLAY is set
26
MESSAGE="$PROGNAME: $*"
27
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
28
if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
29
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
34
# exit script with error
39
internal_errormsg () {
40
# exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
41
# One big call to message() for the sake of xmessage; if we had two then
42
# the user would have dismissed the error we want reported before seeing the
43
# request to report it.
45
"Please report the installed version of the \"x11-common\"" \
46
"package and the complete text of this error message to" \
47
"<debian-x@lists.debian.org>."
50
# initialize variables for use by all session scripts
52
OPTIONFILE=/etc/X11/Xsession.options
54
SYSRESOURCES=/etc/X11/Xresources
55
USRRESOURCES=$HOME/.Xresources
57
SYSSESSIONDIR=/etc/X11/Xsession.d
58
USERXSESSION=$HOME/.xsession
59
USERXSESSIONRC=$HOME/.xsessionrc
60
ALTUSERXSESSION=$HOME/.Xsession
61
ERRFILE=$HOME/.xsession-errors
63
# attempt to create an error file; abort if we cannot
64
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
65
[ ! -L "$ERRFILE" ]; then
67
elif ERRFILE=$(tempfile 2> /dev/null); then
68
if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
69
message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
70
"\"$ERRFILE\"; look for session log/errors in" \
71
"\"$TMPDIR/xsession-$USER\"."
74
errormsg "unable to create X session log/error file; aborting."
77
# truncate ERRFILE if it is too big to avoid disk usage DoS
78
if [ "`stat -c%s \"$ERRFILE\"`" -gt 500000 ]; then
80
tail -c 500000 "$ERRFILE" > "$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"
83
exec >>"$ERRFILE" 2>&1
85
echo "$PROGNAME: X session started for $LOGNAME at $(date)"
87
# sanity check; is our session script directory present?
88
if [ ! -d "$SYSSESSIONDIR" ]; then
89
errormsg "no \"$SYSSESSIONDIR\" directory found; aborting."
92
# Attempt to create a file of non-zero length in /tmp; a full filesystem can
93
# cause mysterious X session failures. We do not use touch, :, or test -w
94
# because they won't actually create a file with contents. We also let standard
95
# error from tempfile and echo go to the error file to aid the user in
96
# determining what went wrong.
97
WRITE_TEST=$(tempfile)
98
if ! echo "*" >>"$WRITE_TEST"; then
99
message "warning: unable to write to ${WRITE_TEST%/*}; X session may exit" \
104
# use run-parts to source every file in the session directory; we source
105
# instead of executing so that the variables and functions defined above
106
# are available to the scripts, and so that they can pass variables to each
108
SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
109
if [ -n "$SESSIONFILES" ]; then
111
for SESSIONFILE in $SESSIONFILES; do
119
# vim:set ai et sts=2 sw=2 tw=80: