3 # LightDM wrapper to run around X sessions.
5 echo "Running X session wrapper"
8 # pretty-print messages of arbitrary length; use xmessage if it
9 # is available and $DISPLAY is set
10 MESSAGE="$PROGNAME: $*"
11 echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
12 if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
13 echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
18 # exit script with error
23 # temporary storage of error messages
24 ERR=$(mktemp --tmpdir config-err-XXXXXX)
26 source_with_error_check () {
28 echo "Loading $CONFIG_FILE"
29 BASH_VERSION= . "$CONFIG_FILE" 2>"$ERR"
30 if [ -s "$ERR" ]; then
31 . /usr/lib/lightdm/config-error-dialog.sh
33 cat "$ERR" >>/dev/stderr
38 for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
39 if [ -f "$file" ]; then
40 source_with_error_check "$file"
45 if type xrdb >/dev/null 2>&1; then
46 xresourcedir="/etc/X11/Xresources"
47 if [ -d "$xresourcedir" ]; then
48 for file in $xresourcedir/*; do
49 echo "Loading resource: $file"
53 xresourcefile="$HOME/.Xresources"
54 if [ -f "$xresourcefile" ]; then
55 echo "Loading resource: $xresourcefile"
56 xrdb -merge "$xresourcefile"
61 if type setxkbmap >/dev/null 2>&1; then
62 for file in "/etc/X11/Xkbmap" "$HOME/.Xkbmap"; do
63 if [ -f "$file" ]; then
64 echo "Loading keymap: $file"
65 setxkbmap `cat "$file"`
71 # Load xmodmap if not using XKB
72 if type xmodmap >/dev/null 2>&1; then
73 if [ -z "$XKB_IN_USE" ]; then
74 for file in "/etc/X11/Xmodmap" "$HOME/.Xmodmap"; do
75 if [ -f "$file" ]; then
76 echo "Loading modmap: $file"
85 # Run all system xinitrc shell scripts.
86 xinitdir="/etc/X11/xinit/xinitrc.d"
87 if [ -d "$xinitdir" ]; then
88 for script in $xinitdir/*; do
89 echo "Loading xinit script $script"
90 if [ -x "$script" -a ! -d "$script" ]; then
96 # Load Xsession scripts
97 # OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
98 # by the scripts to work
99 xsessionddir="/etc/X11/Xsession.d"
100 OPTIONFILE=/etc/X11/Xsession.options
101 USERXSESSION=$HOME/.xsession
102 USERXSESSIONRC=$HOME/.xsessionrc
103 ALTUSERXSESSION=$HOME/.Xsession
105 if [ -d "$xsessionddir" ]; then
106 for i in `ls $xsessionddir`; do
107 script="$xsessionddir/$i"
108 echo "Loading X session script $script"
109 if [ -r "$script" -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
115 echo "X session wrapper complete, running session $@"