~ubuntu-branches/ubuntu/trusty/xorg-lts-xenial/trusty-updates

« back to all changes in this revision

Viewing changes to debian/local/Xsession

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2016-06-30 12:15:22 UTC
  • Revision ID: package-import@ubuntu.com-20160630121522-h2f731o0rdxrve6k
Tags: 1:7.7+13ubuntu3~trusty1
Backport for lts-xenial stack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# /etc/X11/Xsession
 
4
#
 
5
# global Xsession file -- used by display managers and xinit (startx)
 
6
 
 
7
# $Id: Xsession 967 2005-12-27 07:20:55Z dnusinow $
 
8
 
 
9
set -e
 
10
 
 
11
PROGNAME=Xsession
 
12
 
 
13
message () {
 
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 -
 
20
  fi
 
21
}
 
22
 
 
23
message_nonl () {
 
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 -
 
30
  fi
 
31
}
 
32
 
 
33
errormsg () {
 
34
  # exit script with error
 
35
  message "$*"
 
36
  exit 1
 
37
}
 
38
 
 
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.
 
44
  errormsg "$*" \
 
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>."
 
48
}
 
49
 
 
50
# initialize variables for use by all session scripts
 
51
 
 
52
OPTIONFILE=/etc/X11/Xsession.options
 
53
 
 
54
SYSRESOURCES=/etc/X11/Xresources
 
55
USRRESOURCES=$HOME/.Xresources
 
56
 
 
57
SYSSESSIONDIR=/etc/X11/Xsession.d
 
58
USERXSESSION=$HOME/.xsession
 
59
USERXSESSIONRC=$HOME/.xsessionrc
 
60
ALTUSERXSESSION=$HOME/.Xsession
 
61
ERRFILE=$HOME/.xsession-errors
 
62
 
 
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
 
66
  chmod 600 "$ERRFILE"
 
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\"."
 
72
  fi
 
73
else
 
74
  errormsg "unable to create X session log/error file; aborting."
 
75
fi
 
76
 
 
77
# truncate ERRFILE if it is too big to avoid disk usage DoS
 
78
if [ "`stat -c%s \"$ERRFILE\"`" -gt 500000 ]; then
 
79
  T=`mktemp -p "$HOME"`
 
80
  tail -c 500000 "$ERRFILE" > "$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"
 
81
fi
 
82
 
 
83
exec >>"$ERRFILE" 2>&1
 
84
 
 
85
echo "$PROGNAME: X session started for $LOGNAME at $(date)"
 
86
 
 
87
# sanity check; is our session script directory present?
 
88
if [ ! -d "$SYSSESSIONDIR" ]; then
 
89
  errormsg "no \"$SYSSESSIONDIR\" directory found; aborting."
 
90
fi
 
91
 
 
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" \
 
100
          "with an error"
 
101
fi
 
102
rm -f "$WRITE_TEST"
 
103
 
 
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
 
107
# other
 
108
SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
 
109
if [ -n "$SESSIONFILES" ]; then
 
110
  set +e
 
111
  for SESSIONFILE in $SESSIONFILES; do
 
112
    . $SESSIONFILE
 
113
  done
 
114
  set -e
 
115
fi
 
116
 
 
117
exit 0
 
118
 
 
119
# vim:set ai et sts=2 sw=2 tw=80: