]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - debian/lightdm-session
If we aren't in a multi-seat environment, pass logind XDG_VTNR=0 instead of 1
[sojka/lightdm.git] / debian / lightdm-session
1 #!/bin/sh
2 #
3 # LightDM wrapper to run around X sessions.
4
5 echo "Running X session wrapper"
6
7 message () {
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 -
14   fi
15 }
16
17 errormsg () {
18   # exit script with error
19   message "$*"
20   exit 1
21 }
22
23 # Load profile
24 for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
25     if [ -f "$file" ]; then
26         echo "Loading profile from $file";
27         . "$file"
28     fi
29 done
30
31 # Load resources
32 xresourcedir="/etc/X11/Xresources"
33 if [ -d "$xresourcedir" ]; then
34     for file in $xresourcedir/*; do
35         echo "Loading resource: $file"
36         xrdb -nocpp -merge "$file"
37     done
38 fi
39 xresourcefile="$HOME/.Xresources"
40 if [ -f "$xresourcefile" ]; then
41     echo "Loading resource: $xresourcefile"
42     xrdb -nocpp -merge "$xresourcefile"
43 fi
44
45 # Load keymaps
46 for file in "/etc/X11/Xkbmap" "$HOME/.Xkbmap"; do
47     if [ -f "$file" ]; then
48         echo "Loading keymap: $file"
49         setxkbmap `cat "$file"`
50         XKB_IN_USE=yes
51     fi
52 done    
53
54 # Load xmodmap if not using XKB
55 if [ -z "$XKB_IN_USE" ]; then
56     for file in "/etc/X11/Xmodmap" "$HOME/.Xmodmap"; do
57         if [ -f "$file" ]; then
58            echo "Loading modmap: $file"
59            xmodmap "$file"
60         fi
61     done
62 fi
63
64 unset XKB_IN_USE
65
66 # Run all system xinitrc shell scripts.
67 xinitdir="/etc/X11/xinit/xinitrc.d"
68 if [ -d "$xinitdir" ]; then
69     for script in $xinitdir/*; do
70         echo "Loading xinit script $script"
71         if [ -x "$script" -a ! -d "$script" ]; then
72             . "$script"
73         fi
74     done
75 fi
76
77 # Load Xsession scripts
78 # OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
79 # by the scripts to work
80 xsessionddir="/etc/X11/Xsession.d"
81 OPTIONFILE=/etc/X11/Xsession.options
82 USERXSESSION=$HOME/.xsession
83 USERXSESSIONRC=$HOME/.xsessionrc
84 ALTUSERXSESSION=$HOME/.Xsession
85
86 if [ -d "$xsessionddir" ]; then
87     for i in `ls $xsessionddir`; do
88         script="$xsessionddir/$i"
89         echo "Loading X session script $script"
90         if [ -r "$script"  -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
91             . "$script"
92         fi
93     done
94 fi
95
96 echo "X session wrapper complete, running session $@"
97
98 exec $@