summaryrefslogtreecommitdiff
path: root/extra-modes/xephyr-gdm/src/xephyr-gdm
blob: 456254b2d78da6f6d5e769449d4ce7d2d24382e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash

# Copyright (C) 2004-2007 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

# This configuration runs Xephyr on gdm, using gdmdynamic

XEPHYR_WRAPPER=${MDM_SCRIPTS}/xephyr-wrapper

RETRIES=2
SLEEP=1
GDMDYNAMIC="gdmdynamic -t $RETRIES -s $SLEEP"
GDM_SOCKET='/var/run/gdm_socket'

export XAUTHORITY='/var/lib/gdm/:0.Xauth'

function display_manager_init () {
    # This function should stop running processes, remove logs, links, locks, or
    # anything your display manager might need.
    # Consider calling display_manager_stop here if you don't need anything
    # else.

    # No problem if it's already running...
    display_manager_stop

    /etc/init.d/gdm start
}

function display_manager_start_monoseat () {
    # This function is called when the computer has only 1 video card.
    # You should open only 1 xserver and that's it: normal usage, not multiseat
    # Do NOT configure devices or stuff like that
    # We assume $DISPLAY is already set here.

    $GDMDYNAMIC -a 0=XHandled
    $GDMDYNAMIC -r 0
    # XXX: find a better way to wait for X to start
    sleep 5;
}

function display_manager_start_underneath_xserver () {
    # In case we're using nested xservers (like Xephyr), we'll need to start an
    # xserver to run the nested servers on top of it
    # Don't put login screen on this server!
    # We assume $DISPLAY is already set here.

    $GDMDYNAMIC -a 0=XNotHandled
    $GDMDYNAMIC -r 0
    # XXX: find a better way to wait for X to start
    sleep 5;
}

function display_manager_start_seat () {
    # This is where we start the xserver that will have a login screen
    # In case of multiseat with Xephyr, this function starts the Xephyrs and
    # puts the login screens on them.
    # We assume $DISPLAY is already set here.
    # This function is called by mdm-start-seat, which gives you variables:
    #   - $KEYBOARD and $MOUSE, which point to evdev device nodes.
    #   - $SEAT_NUMBER variable corresponds to the number that the user will
    #     have to press on the keyboard. Might be useful here.
    #   - $MY_SCREEN_SIZE for the size of screen (needed when running nested
    #     xservers)
    #   - $MY_XKB_LAYOUT and $MY_XKB_MODEL, for the keyboard associated with the
    #      seat

    echo "Xephyr :${SEAT_NUMBER} -br"
    echo "       -parent $SEAT_WINDOW_ID"
    echo "       -mouse evdev,,device=$MOUSE"
    echo "       -keybd"
    echo -n "        evdev,,device=$KEYBOARD,xkbmodel=$MY_XKB_MODEL,"
    echo             "xkblayout=$MY_XKB_LAYOUT"
    echo "       -${CONNECTION_TYPE} ${CONNECTION_TARGET} 2>&1 &"



    $GDMDYNAMIC "-a ${SEAT_NUMBER}=${XEPHYR_WRAPPER} -br :${SEAT_NUMBER}   \
    	      -display $DISPLAY						   \
	      -xauthority $XAUTHORITY					   \
    	      -parent $SEAT_WINDOW_ID	   			           \
    	      -mouse evdev,,device=$MOUSE				   \
	      -keybd							   \
	evdev,,device=$KEYBOARD,xkbmodel=$MY_XKB_MODEL,xkblayout=$MY_XKB_LAYOUT"
    $GDMDYNAMIC -r ${SEAT_NUMBER}

    # XXX: We're letting gdm do everything: it will restart Xephyr whenever it
    # dies, it will do a lot of stuff. This way, we won't be able to reconfigure
    # input. We need to find a way to do this, maybe through gdm itself.
    echo "Exiting (gdm will handle the Xephyrs for us)."
    exit 1;
}

function display_manager_stop () {
    # This function should kill everything it has to kill, so that we REALLY
    # stop all the seats, kill all the Xephyrs, remove locks, links and stuff
    # like that.

    if [ -e "$GDM_SOCKET" ]; then
	SERVERS=($(gdmdynamic -l | tr ';' '\n'| cut -d':' -f2 | cut -d',' -f1))
	for i in ${SERVERS[@]}; do
	    $GDMDYNAMIC -d $i
	done
    fi
}